Resend 403 "You can only send testing emails to your own email address": how to fix it

By AI App Medic · Updated · Resend · Email · Edge Functions · DNS

Your app sends a welcome email, an order receipt or an invite. When you try it, the email arrives. When a real user tries it, nothing comes, and the app may still say "Email sent". In the logs of the Edge Function or API route, Resend answered with a 403:

{
  "statusCode": 403,
  "name": "validation_error",
  "message": "You can only send testing emails to your own email address (you@example.com). To send emails to other recipients, please verify a domain at resend.com/domains, and change the `from` address to an email using this domain."
}

This is one of the most common reasons emails "do not work" in apps built with Lovable, Bolt, Cursor or v0. The fix takes about fifteen minutes plus however long your DNS takes.

Why it happens

To let you try the API before you set anything up, Resend gives every account a shared sender on its own domain: onboarding@resend.dev. That sender can only deliver to the email address of your Resend account. Resend's examples and quick start use it, and AI tools copy it into generated code, so the app goes live with a test address in the from field.

Resend needs proof that you control the domain in the from address, and it gets that proof from DNS records. Until a domain of yours is verified and the code uses it, every email to anyone else is refused.

Two related messages come from the same root cause:

Step 1: read the error Resend returned

Before changing anything, confirm this is the error. In a Supabase project, open Edge Functions, pick the function that sends mail, and read its Logs. In Next.js on Vercel, read the function logs for the API route. The Resend dashboard also shows every API request under Logs, including refused ones, with the full response.

If you see nothing at all, not even a refused request in Resend, the email code is not running or is failing earlier, for example on CORS or auth. Start with Edge Function returned a non-2xx status code in that case.

Step 2: add a domain you control

In the Resend dashboard, open Domains and click Add Domain. Use a subdomain of the domain your app already uses, for example mail.yourdomain.com or notify.yourdomain.com. Resend recommends a subdomain, and it has two practical benefits: your app's sending reputation stays separate from your personal or team email, and the new records cannot interfere with the mail setup on your root domain.

If Resend asks for a region, pick the one closest to your backend or your users.

Step 3: add the DNS records exactly as shown

The Records tab lists what to add: a DKIM record and the records for the return path (SPF), and optionally DMARC. Copy the values from that tab, not from a tutorial or screenshot, because the names and values are specific to your domain and can change between accounts. Add them wherever your domain's DNS is managed: Cloudflare, Namecheap, GoDaddy, Porkbun, or your registrar.

Three mistakes cause most stuck verifications:

Check from a terminal before you wait for Resend. Use the names from your Records tab; these are examples:

dig +short TXT resend._domainkey.mail.yourdomain.com
dig +short MX send.mail.yourdomain.com
dig +short TXT send.mail.yourdomain.com

Empty output means the record is not there yet, or is at the wrong name. When all of them answer with the values from the Records tab, click Verify in Resend. Most domains verify within minutes to an hour once the records resolve; DNS changes can take longer on some hosts.

If you have no DMARC record on the root domain yet, add a basic one so mailbox providers trust your mail more. Start in monitoring mode:

Name:  _dmarc
Type:  TXT
Value: v=DMARC1; p=none;

Step 4: change the from address everywhere

Verification alone changes nothing. The code still sends from resend.dev until you change it. Find every place it appears:

grep -rn "resend.dev" --exclude-dir=node_modules --exclude-dir=.next --exclude-dir=dist .

Generated projects often have it in several Edge Functions (one per email type) and sometimes in a shared helper. Replace each one with an address on the exact domain you verified, and better, read it from one setting so this never happens again:

# Supabase Edge Functions
supabase secrets set EMAIL_FROM="Your App <hello@mail.yourdomain.com>"

# Vercel (Next.js API routes): Settings, Environment Variables
EMAIL_FROM=Your App <hello@mail.yourdomain.com>

Supabase Edge Functions see new secrets without a redeploy, but if you changed the code itself, deploy the functions again. On Vercel and Netlify, environment variable changes only reach new deployments, so redeploy. If your Lovable project uses Lovable Cloud, ask Lovable to update the sender in each function and set the secret there.

Use an address people can reply to, or set reply_to to a real inbox. A noreply@ sender on a brand new domain is more likely to land in spam.

Step 5: stop reporting success when the send failed

The reason this bug hides for weeks is that the app never notices. The Resend Node SDK does not throw on an API error. It returns { data: null, error }, and code that only reads data, or ignores the result, carries on as if the email went out:

// Looks fine, sends nothing to real users
await resend.emails.send({ from: 'onboarding@resend.dev', to: email, subject, html })
return { ok: true }

Check the error and pass it on:

const { data, error } = await resend.emails.send({
  from: process.env.EMAIL_FROM!,
  to: email,
  subject,
  html,
})
if (error) {
  console.error('Resend refused the email', error.name, error.message)
  throw new Error('Email could not be sent')
}
return { ok: true, id: data?.id }

Many Supabase Edge Functions call the API with fetch instead of the SDK. fetch does not throw on a 403 either, so check res.ok:

// supabase/functions/_shared/send-email.ts
export async function sendEmail(to: string, subject: string, html: string) {
  const res = await fetch('https://api.resend.com/emails', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${Deno.env.get('RESEND_API_KEY')}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ from: Deno.env.get('EMAIL_FROM'), to, subject, html }),
  })
  const body = await res.json().catch(() => ({}))
  if (!res.ok) {
    console.error('Resend error', res.status, body)
    throw new Error(body.message ?? `Resend returned ${res.status}`)
  }
  return body.id as string
}

Call it from functions that decide the recipient and the content on the server, for example from the signed-in user's own email or an order in the database. Do not expose a function that takes to, subject and html from the browser. Anyone could use it to send mail from your domain, and your domain's reputation is what you just set up. Keep RESEND_API_KEY on the server only; a key in a VITE_ or NEXT_PUBLIC_ variable is public (see why VITE_ keys are public).

Step 6: test with an address that is not yours

Send to a second address you control that is not your Resend login, such as a personal Gmail. The API should return an id, and the email should show in the Resend dashboard under Emails with status Delivered. If it is delivered but lands in spam, give the new domain a few days of normal volume, add DMARC, and make sure the content is not just a link.

Supabase Auth emails are a separate setting

Sign-up confirmations, magic links and password resets are not sent by your code. Supabase Auth sends them, and changing the from in your functions does not affect them. To send them through Resend, open Authentication, then SMTP settings (under Emails) in the Supabase dashboard, enable custom SMTP, and use:

Host:          smtp.resend.com
Port:          465
Username:      resend
Password:      your Resend API key
Sender email:  an address on the domain you verified

A sender on an unverified domain fails here too, and Supabase shows it as Error sending confirmation email. Our guide on Supabase auth emails that never arrive covers the rest of that setup, and email rate limit exceeded explains the limits you hit before custom SMTP is on.

Prevention

FAQ

Can I keep onboarding@resend.dev in production?

No. Resend only allows the resend.dev address for testing, and it can only send to the email address of your own Resend account. Every real user gets the 403.

Why does it work when I test it?

Because you are the one exception. When you sign up with the same email you used for Resend, the message is delivered, so the app looks finished. The first customer with any other address gets nothing.

Can I send from my Gmail or Outlook address?

No. You can only verify a domain whose DNS you control, and nobody but Google can add records to gmail.com. Buy a domain if you do not have one; the one your app already uses for its custom domain works.

Will the Resend DNS records break my existing email?

Not if you verify a subdomain such as mail.yourdomain.com. Resend's records sit on that subdomain and below it, so the MX records that deliver mail to your Google Workspace or other inbox on the root domain are not touched.

Does this also fix Supabase sign-up and password reset emails?

No. Those are sent by Supabase Auth, not your code. To send them through Resend, turn on custom SMTP in the Supabase dashboard with host smtp.resend.com, port 465, user resend and your API key as the password, and a sender on the verified domain.

Related guides