Skip to content

Cloudflare Worker Email Server

Maintained
Sh4yy/cloudflare-email

A simple proxy server for sending free transactional emails through Cloudflare Workers using MailChannels, with support for HTML emails, multiple recipients, CC, BCC, and customizable sender/recipient names.

View on GitHub
Stars
1.6k
Forks
367
Watchers
1.6k
Open issues
13

A simple proxy server that enables sending free transactional emails through Cloudflare Workers using MailChannels.

Key Features

  • Free Email Sending: Leverage MailChannels to send transactional emails without cost
  • HTML Support: Send both plain text and HTML formatted emails
  • Multiple Recipients: Support for sending to multiple recipients, as well as CC and BCC
  • Customizable Names: Add sender and recipient names for better email presentation
  • Reply-To Headers: Configure custom reply-to addresses
  • Secure Authentication: Token-based authentication for secure API access
  • Easy Deployment: Quick deployment to Cloudflare Workers

Setup Requirements

Before using this server, you’ll need to configure:

  • SPF Records: Add a TXT record to authorize MailChannels to send on your behalf
  • Optional DKIM: Implement DKIM for improved email deliverability and security
  • Authentication Token: Set up a secure token for API authentication

Implementation Example

After deploying, send emails with a simple API request:

// Basic email example
fetch('https://your-worker.workers.dev/api/email', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "to": "recipient@example.com",
    "from": "sender@yourdomain.com",
    "subject": "Important Notification",
    "text": "This is a plain text message",
    "html": "<h1>Hello</h1><p>This is an HTML formatted message</p>"
  })
});

Advanced Usage

The API supports several advanced features:

  • Named Recipients: { "email": "john@example.com", "name": "John Doe" }
  • Multiple Recipients: Send to arrays of email addresses
  • HTML Content: Include formatted content with the html parameter
  • CC/BCC Support: Add carbon copy and blind carbon copy recipients
  • Reply-To Headers: Specify custom reply-to addresses

When to Use

  • When you need to send transactional emails from serverless functions
  • When you want to avoid the costs of traditional email service providers
  • When you’re already using Cloudflare Workers for other functionality
  • When you need basic but flexible email capabilities (HTML, multiple recipients)
  • When you want to leverage your own domain for sending emails

Frequently Asked Questions

Is this really free to use?

Yes, this service leverages MailChannels’ integration with Cloudflare Workers, which allows for free transactional email sending.

How do I fix the “Domain Lockdown” error?

Add a specific TXT record named _mailchannels with the value v=mc1 cfid=yourdomain.workers.dev to verify domain ownership.

Does this support file attachments?

The basic implementation doesn’t include attachments, but the code could be extended to support them.

What are the sending limits?

The limits are determined by MailChannels and Cloudflare Workers’ execution limits, not the proxy server itself.

Important Notes

End of Life Notice - Cloudflare Workers & MailChannels you can find the issue here: https://github.com/Sh4yy/cloudflare-email/issues/19

Similar open-source projects, ranked by shared categories and tags.

All Tools projects →