9/1/2025
Cloudflare & Email Binding

You don't need to have an email server to send emails with Cloudflare Worker. Just let Cloudflare validate the email address you're using and Cloudflare will forward incoming emails to it.
Requirements
There are 3 things you need to have in your Cloudflare account to be able to send emails:
- Domain - You need to have an active domain in your Cloudflare account. This doesn't mean you have to buy it from them - it's enough to set your DNS records to point to Cloudflare.
- Email - You need to have an active email address. It doesn't have to be associated with the domain from the previous point. It can be a Gmail account or any other account you have full access to. This can also be the email you use to log in to Cloudflare. This email must be added to the 'Destination addresses' in the 'Email Routing' settings for the domain from previous point, which will make it active.
- Routing rules - You need to have an email address added to the 'Routing rules' in the 'Email Routing'. This address is part of the domain from the first point and will be used to forward emails to the email from the previous point.
I may have described it a bit complicated, but once you start adding the settings one after another, you will understand it correctly.
Binding
In your Nuxt project that uses Cloudflare Worker, there should be a wrangler.jsonc
or wrangler.toml
file for configuration. You need to add the following settings to it:
// wrangler.jsonc
{
"send_email": [
{
"name": "INFO_EMAIL", // free text - it's good to have meaning
"destination_address": "your@valid.email" // email from point 2 above
}
]
}
These are all the initial environment settings for the machine to work. And do not forget to update Cloudflare types.
npx wrangler types
Usage
The easiest way is to add an API endpoint to the Nitro environment. For example /api/send-info-email
. This endpoint needs to initialize the Cloudflare binding so we can use it directly. This is the coolest part. It can be done in one line:
// Accessing Email binding
const env = event.context.cloudflare?.env;
And as you might guess, env
gives you full access to the Email binding and you can send emails at will.
// Sending an email
await env.INFO_EMAIL.send({
sender,
recipient,
content
});
Extremely simple and incredibly elegant solution. DX to the MAX.