Recipe: Send email from the Edge
Send transactional email from Cloudflare Workers or other Edge runtimes with Notify’s HTTPS API.
Edge runtimes speak fetch. Notify is a single HTTPS POST — no Node-only SMTP sockets required.
export default {
async fetch(request: Request, env: { NOTIFY_API_KEY: string }) {
const res = await fetch('https://notify.cx/api/email/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': env.NOTIFY_API_KEY
},
body: JSON.stringify({
to: 'user@example.com',
subject: 'Hello from the edge',
message: '<p>Sent from a Worker.</p>',
from: 'noreply@your-verified-domain.com'
})
});
return new Response(await res.text(), { status: res.status });
}
};
Store the key in Worker secrets / Edge env — not in the client bundle.