example email broadcast
1
2const Page = () => {
3 async function sendEmails() {
4 const subject = "Testing email";
5 fetch('/api/email/', {
6 method: "POST",
7 body: JSON.stringify({ subject }),
8 })
9 .then((res) => res.json())
10 .then((data) => {
11 });
12 }
13 return(
14 <>
15 <button onClick={sendEmails}>Send emails to your customers</button>
16 </>
17 );
18}
code snippet from /app/api/email/route.ts
1
2const { data, error } = await resend.emails.send({
3 from: "info@yourdomain.com",
4 to: emails,
5 subject: request.subject,
6 html: "<strong>This is an example email sent from Resend!</strong>",
7});
8