跳到正文

Cloudflare Worker Email Server

维护中
Sh4yy/cloudflare-email

通过 Cloudflare Workers 和 MailChannels 免费发送事务性邮件的简单代理服务,支持 HTML 邮件、多个收件人、抄送、密送以及自定义发件人/收件人名称。

在 GitHub 查看
星标
1600
Fork
367
关注
1600
未关闭 Issue
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": "[email protected]",
    "from": "[email protected]",
    "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": "[email protected]", "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

按共同分类和标签排序的同类开源项目。

全部工具项目 →