Skip to content

Deploy your own SMTP relay on Cloudflare

Most web hosts only offer SMTP, which browsers can't speak. Deploy a tiny open-source relay Worker to your own Cloudflare account so the extension can send through your SMTP server.

Last updated December 1, 2026

Browser extensions can’t open SMTP connections, and most hosting (cPanel, GoDaddy and similar) only offers SMTP. The relay closes that gap: a tiny Cloudflare Worker that accepts a message from your extension and sends it through your SMTP server.

You run it, not us. It’s deployed into your own Cloudflare account. We never host it, never see its secrets and can’t reach it.

What the relay is

  • A single open-source Worker, MIT-licensed, in apps/relay of the repository.
  • Stateless. No database, no storage, no logs of messages, subjects or recipients.
  • It connects to your SMTP server with Cloudflare’s outbound sockets on port 465 or 587 (also 2465 and 2525). Port 25 isn’t available to Workers.
  • With starttls, if your server doesn’t offer STARTTLS the relay stops before sending your password; it never falls back to plain text.
  • It only accepts requests carrying your relay secret, and only sends as addresses you list.
  • Optionally it can add a copy of each message to Gmail’s Sent Mail over IMAP, using a Gmail app password you provide.

Deploy it

  1. You need a free Cloudflare account. Workers’ free plan is enough for personal volume, but check Cloudflare’s current limits.
  2. Press the button: Deploy to Cloudflare. Cloudflare copies the relay into a repository in your GitHub account and deploys it to your Cloudflare account.
  3. Fill in the settings when asked. If a value isn’t offered during deployment, add it afterwards under Workers & Pages → your Worker → Settings → Variables and Secrets, and use Secret for passwords.
  4. Note the Worker’s address, like https://sendas-relay.your-subdomain.workers.dev. You’ll enter it in the extension.

Settings and secrets

Name Required What it is
RELAY_SECRET yes A long random string. The extension sends it with every request; the relay refuses everything else. Use at least 32 random characters (the extension can generate one).
SMTP_HOST yes Your SMTP server, for example mail.yourbiz.com.
SMTP_PORT yes 465 (SSL/TLS) or 587 (STARTTLS). 2465 and 2525 also work.
SMTP_SECURITY yes tls for implicit SSL/TLS (port 465; a few providers also use 2465), starttls for 587 and 2525. Follow your provider’s page: see the SMTP presets.
SMTP_USER yes The SMTP login, usually the full email address.
SMTP_PASS yes The SMTP password, preferably an app password or SMTP key, not your main mailbox password. Store it as a secret.
ALLOWED_FROM yes Comma-separated addresses the relay may send as, e.g. you@yourbiz.com. Anything else is refused.
GMAIL_ADDRESS no Your Gmail address. With the next setting, enables adding a copy to Sent Mail over IMAP.
GMAIL_APP_PASSWORD no A Gmail app password (needs 2-Step Verification). Store as a secret.

The relay’s authors can’t see any of these. They live as variables and secrets on your Worker.

Use an app password, not your main password. Yahoo, AOL, iCloud, Fastmail and others require one, and transactional providers give you keys. The SMTP presets list which and where to create them.

A Gmail app password gives access to your whole mailbox over IMAP, not only to Sent Mail. Only enable the IMAP copy if you accept that, and revoke the password in your Google account if you stop using it. The default filter-based copy needs none of this.

Use it from the extension

In the extension settings add an address, choose Own relay, enter the relay’s URL and the RELAY_SECRET, then run Test connection. See the setup guide.

Update or delete your relay

  • Update: the deployment created a repository in your GitHub account. Pull updates from the upstream repository there and Cloudflare redeploys. Releases note when the relay changes.
  • Rotate the secret: change RELAY_SECRET in the Worker’s settings and in the extension.
  • Delete: in the Cloudflare dashboard open Workers & Pages, choose the Worker and delete it. Its secrets go with it. Also delete the copied repository if you don’t want it.
  • Revoke SMTP access: change the mailbox password at your host. That cuts access no matter what remains deployed.

Troubleshooting

Symptom Likely cause
Unauthorized The RELAY_SECRET in the extension doesn’t match the Worker’s.
Server rejected the username/password (535) Wrong SMTP_USER or SMTP_PASS, or you used your main password where an app password is required. Most hosts want the full email address.
Couldn’t connect / timeout Wrong host or port, a port and TLS/STARTTLS mismatch, or the host blocks connections from Cloudflare. Try 465 with tls, or ask your host.
The server doesn’t offer STARTTLS SMTP_SECURITY is starttls but the port expects implicit TLS. Use tls on 465.
TLS or certificate error Use the host name your SMTP server’s certificate is issued for (often the server’s name).
Sender not allowed The From address isn’t in ALLOWED_FROM.