我正在使用resend.com尝试向两个不同的用户发送带有不同变量的电子邮件。
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);
}
};
字符串
这会发送给玩家1,但不会发送给玩家2,即使电子邮件对两者都是正确的。我如何向两个用户发送两封电子邮件?
他们的API允许你通过向“to”传递一组字符串来发送多达50封电子邮件,但这并不理想,因为这意味着双方都可以看到对方的电子邮件https://resend.com/docs/api-reference/emails/send-email
1条答案
按热度按时间yeotifhr1#
我想现在回答你已经晚了,因为这个问题已经过去5个月了。
但是对于那些仍然在学习和搜索这个查询的人来说!
这里:
字符串