How do I get gmail.com domain verified?

341 Views Asked by At
{
    "data": null,
    "error": {
        "statusCode": 403,
        "message": "The gmail.com domain is not verified. Please, add and verify your domain on https://resend.com/domains",
        "name": "validation_error"
    }
}

I get the error above when trying to send emails through Resend

Here is my code,

route.js file:

// import { EmailTemplate } from '../../../components/EmailTemplate';
import { NextResponse } from 'next/server';
import { Resend } from 'resend';



export async function POST() {
    const resend = new Resend(process.env.RESEND_API_KEY);
    const fromEmail = process.env.FROM_EMAIL;   
    try {
        const data = await resend.emails.send({
        from: fromEmail,
        to: `[email protected]`,
        subject: 'Hello world',
        react: <><p>Email Body</p></>,
        });

        return NextResponse.json(data);
    } catch (error) {
        return NextResponse.json({ error });
    }
}

.env.local file:

RESEND_API_KEY =***********************
FROM_EMAIL [email protected]

And my Domain and Email have been added and verified by Resend

I tried looking online, changed the API Key, even changed Domains. Thank you for all you help!

1

There are 1 best solutions below

0
On BEST ANSWER

For your code:

const fromEmail = process.env.FROM_EMAIL;   
try {
    const data = await resend.emails.send({
    from: fromEmail,
    to: `[email protected]`,

Ensure that the fromEmail variable corresponds to a domain you have verified. For instance, if you own the domain "example.com" and have already verified it (by adding MX/TXT records to your DNS service provider), you should use an email address from that domain as your sender. For example:

from: "[email protected]"

RESEND Error Docs: https://resend.com/docs/api-reference/errors