I am using resend.com to try and send an email with different variables to two different users.
import type { NextApiRequest, NextApiResponse } from "next";
import { EmailTemplate } from "../../components/emails/EmailTemplate";
import { Resend } from "resend";
import { supabase } from "../../../initSupabase";
const resend = new Resend(process.env.NEXT_PUBLIC_RESEND_KEY);
export default async (req: NextApiRequest, res: NextApiResponse) => {
try {
const { player1, player2, player1Email, player2Email } = req.body;
const player1Data = await resend.emails.send({
from: "Acme <[email protected]>",
to: [player1Email],
subject: "Hello player 1",
react: EmailTemplate({ firstName: player1, secondName: player1Email }),
});
const player2Data = await resend.emails.send({
from: "Acme <[email protected]>",
to: [player2Email],
subject: "Hello player 2",
react: EmailTemplate({ firstName: player2, secondName: player2Email }),
});
res.status(200).json({ player1Data, player2Data });
} catch (error) {
res.status(400).json(error);
}
};
This sends to player1 but not to player2 even though the emails are correct for both. How can I send both emails to both users?
Their api allows you to send up to 50 emails by passing an array of strings into 'to' but this is not ideal as it means both parties can see each others email https://resend.com/docs/api-reference/emails/send-email
i guess its already late to answer you as its been 5months already about this question.
But for the people who are still learning and searching for this query!
here: