Reputation: 1
I'm having a problem with sending mails via resend with a react body. When i send my mails with a text body i get status 200, the log says that it is delivered and i can see the mail in my mailbox. When i send an email with a react body the first two just work fine but i dont get the email in my mailbox (i have looked in my spam folder.
route.ts
import { NextResponse } from 'next/server';
import { EmailTemplate } from '../../components/emailTemplate';
import { Resend } from 'resend';
import { getSession } from '@auth0/nextjs-auth0';
import * as React from 'react';
const resend = new Resend(process.env.RESEND_API_KEY);
export async function POST(request: Request) {
// get email info
const { body } = request;
// decode body
let passedValue = await new NextResponse(body).text();
let valueToJson = JSON.parse(passedValue);
const { email } = valueToJson;
console.log(email);
// get current user
const session = await getSession();
const user = session?.user;
// try to send email
try {
console.log("in try");
const data = await resend.emails.send({
from: 'Stage <[email protected]>',
to: ['[email protected]'],
subject: 'Uitnodiging Energy!',
// text: 'text',
react: EmailTemplate({ firstName: 'John' }) as React.ReactElement,
// react: EmailTemplate({ email:email, companyId:'clte87w710003glwww0slvgvp', username:user?.given_name }),
});
console.log(data);
return Response.json(data);
} catch (error) {
console.log(error);
return Response.json({ error });
}
}
emailTemplate.tsx
import * as React from 'react';
interface EmailTemplateProps {
firstName: string;
}
export const EmailTemplate: React.FC<Readonly<EmailTemplateProps>> = ({
firstName,
}) => (
<div>
<h1>Welcome, {firstName}!</h1>
</div>
);
export default EmailTemplate;
**Resend version: ** ^3.2.0
I have looked for solutions online but unfortunately there is not many to find. I also tried to send a mail with a html body but that also doesn't work.
Upvotes: 0
Views: 334
Reputation: 1
Meanwhile, it appears that the email on the mail server is blocked as span because we have not purchased our own ip address. Since it is blocked on the mail server, I also could not see the email in my spam folder.
Upvotes: 0