{"id":15509687,"url":"https://github.com/willin/cloudflare-send-email-service","last_synced_at":"2025-04-23T02:41:43.185Z","repository":{"id":217578830,"uuid":"725880039","full_name":"willin/cloudflare-send-email-service","owner":"willin","description":"Cloudflare Email Worker as a Service / API. Cloudflare Email Routing 免费邮件发送（作为 Service 服务）用于 Workers/Pages 项目中。","archived":false,"fork":false,"pushed_at":"2023-12-01T04:03:25.000Z","size":8,"stargazers_count":22,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T22:27:58.006Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"willin","custom":"https://afdian.net/@willin"}},"created_at":"2023-12-01T04:03:09.000Z","updated_at":"2025-04-04T09:42:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f66e9cf-6486-46a7-a9d9-d7fd03998eab","html_url":"https://github.com/willin/cloudflare-send-email-service","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"d3bb5ce20a5bd4211916ce34813226f1edd9b05d"},"previous_names":["willin/cloudflare-send-email-service"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fcloudflare-send-email-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fcloudflare-send-email-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fcloudflare-send-email-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fcloudflare-send-email-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willin","download_url":"https://codeload.github.com/willin/cloudflare-send-email-service/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250360234,"owners_count":21417716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T09:43:29.600Z","updated_at":"2025-04-23T02:41:43.158Z","avatar_url":"https://github.com/willin.png","language":"JavaScript","funding_links":["https://github.com/sponsors/willin","https://afdian.net/@willin","https://paypal.me/willinwang"],"categories":[],"sub_categories":[],"readme":"[中文版](#Chinese) / [English](#English)\n\n# Cloudflare Email Worker as a Service / API\n\nCloudflare Email Routing 免费邮件发送（作为 Service 服务）用于 Workers/Pages 项目中。\n\n## 赞助 Sponsor\n\n如果您对本项目感兴趣，可以通过以下方式支持我：\n\n- 关注我的 Github 账号：[@willin](https://github.com/willin) [![github](https://img.shields.io/github/followers/willin.svg?style=social\u0026label=Followers)](https://github.com/willin)\n- 参与 [爱发电](https://afdian.net/@willin) 计划\n- 支付宝或微信[扫码打赏](https://user-images.githubusercontent.com/1890238/89126156-0f3eeb80-d516-11ea-9046-5a3a5d59b86b.png)\n\nDonation ways:\n\n- Github: \u003chttps://github.com/sponsors/willin\u003e\n- Paypal: \u003chttps://paypal.me/willinwang\u003e\n- Alipay or Wechat Pay: [QRCode](https://user-images.githubusercontent.com/1890238/89126156-0f3eeb80-d516-11ea-9046-5a3a5d59b86b.png)\n\n## 许可证 License\n\nApache-2.0\n\n\u003ca id=\"Chinese\"\u003e\u003c/a\u003e\n\n## 准备工作\n\n1. 准备一个域名，例如 `example.com`。现在，在 [cloudflare-dashboard](https://dash.cloudflare.com/) 中添加一个网站并构建您的域名。这可能需要大约 30 分钟。\n2. 选择您的站点和域名，[启用电子邮件路由](https://developers.cloudflare.com/email-routing/get-started/enable-email-routing/)。这可能需要大约 5 分钟。\n3. 安装 wrangler 以部署 cf worker。确保您的 node 版本 \u003e= 16.13.0 并运行：\n\n```sh\nnpm install wrangler@latest -g\n```\n\n## 设置\n\n1. 获取代码\n\n```sh\ngit clone git@github.com:willin/cloudflare-send-email-service.git\n```\n\n2. 部署您的 worker\n\n```sh\n# 建议改个名字\nwrangler deploy  --name send-email-worker-service\n```\n\n3. 配置域名解析\n\n创建第一个 TXT 解析记录：\n\n- Name: `yourdomain.com`\n- Value: `v=spf1 a mx include:relay.mailchannels.net ~all`\n\n创建第二个 TXT 解析记录：\n\n- Name: `_mailchannels.yourdomain.com`\n- Value: `v=mc1 cfid=yourdomain.workers.dev` (`cfid` 会在你测试的报错信息中看到，解析后等待生效大约需要半天)\n\n\u003e 更多关于 [Domain Lockdown](https://support.mailchannels.com/hc/en-us/articles/16918954360845-Secure-your-domain-name-against-spoofing-with-Domain-Lockdown) 错误的信息\n\n4. 设置 DKIM\n\n这一步是可选的，但强烈推荐您去做。您可以参考 [MailChannels 文档](https://support.mailchannels.com/hc/en-us/articles/7122849237389-Adding-a-DKIM-Signature) 步骤来完成域名的 DKIM 设置。\n\n## API 文档\n\n### 地址\n\n`http://{{your-cf-worker-prefix}}.workers.dev/`\n\n### 方法\n\n`POST`\n\n### 参数\n\n| 名称              | 类型     | 描述                   |\n| ----------------- | -------- | ---------------------- |\n| `sender_email`    | `string` | 发件人的电子邮件地址。 |\n| `sender_name`     | `string` | 发件人的名称。         |\n| `recipient_email` | `string` | 收件人的电子邮件地址。 |\n| `subject`         | `string` | 电子邮件的主题。       |\n| `message`         | `string` | 电子邮件的正文。       |\n\n### 示例请求\n\n```sh\ncurl -d\"sender_email=admin@yourdomain.com\u0026sender_name=Test\u0026recipient_email=your-dest@example.com\u0026subject='Hello Guy!'\u0026message='My first email sent!'\" \"http://your-cf-worker-prefix.workers.dev/\"\n```\n\n注意，端点 URL 中的 `your-cf-worker-prefix` 需要替换为实际的 worker 前缀。\n\n\u003ca id=\"English\"\u003e\u003c/a\u003e\n\n# Cloudflare Email Worker as a Service / API\n\nA private api/worker service for sending email powered by Cloudflare worker project.\n\n## Prepare Job\n\n1. Prepare a domian, such as `example.com`. Now, add a website in [cloudflare-dashboard](https://dash.cloudflare.com/) and build your domain. It maybe cost you about 30min.\n2. Select your site and domain, [Enable Email Routing](https://developers.cloudflare.com/email-routing/get-started/enable-email-routing/). It maybe cost you about 5min.\n3. Install warngler for delpoy cf worker. Ensure your node version \u003e= 16.13.0 and run :\n\n```sh\nnpm install wrangler@latest -g\n```\n\n## Setup\n\n1. Get the code\n\n```sh\ngit clone git@github.com:willin/cloudflare-send-email-service.git\n```\n\n2. Deploy your worker\n\n```sh\nwrangler deploy  --name send-email-worker-service\n```\n\n3. Config DNS records\n\nAdd a TXT record to your domain with the following values:\n\n- Name: `yourdomain.com`\n- Value: `v=spf1 a mx include:relay.mailchannels.net ~all`\n\nNote: If you're facing [Domain Lockdown](https://support.mailchannels.com/hc/en-us/articles/16918954360845-Secure-your-domain-name-against-spoofing-with-Domain-Lockdown) error, follow the below steps:\n\n- Name: `_mailchannels.yourdomain.com`\n- Value: `v=mc1 cfid=yourdomain.workers.dev` (the value of `cfid` will also be present in the error response)\n\n4. Setup DKIM\n\nThis step is optional, but highly recommended. DKIM is a DNS record that helps prevent email spoofing. You may follow the steps listed in the [MailChannels documentation](https://support.mailchannels.com/hc/en-us/articles/7122849237389-Adding-a-DKIM-Signature) to set up DKIM for your domain.\n\n## API Documentation\n\n### Endpoint\n\n`http://{{your-cf-worker-prefix}}.workers.dev/`\n\n### Method\n\n`POST`\n\n### Parameters\n\n| Name              | Type     | Description                         |\n| ----------------- | -------- | ----------------------------------- |\n| `sender_email`    | `string` | The email address of the sender.    |\n| `sender_name`     | `string` | The name of the sender.             |\n| `recipient_email` | `string` | The email address of the recipient. |\n| `subject`         | `string` | The subject of the email.           |\n| `message`         | `string` | The message body of the email.      |\n\n### Example Request\n\n```sh\ncurl -d\"sender_email=admin@yourdomain.com\u0026sender_name=Demo\u0026recipient_email=your-dest@example.com\u0026subject='Hello Guy!'\u0026msg_data='My first email sent!'\" \"http://your-cf-worker-prefix.workers.dev/\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillin%2Fcloudflare-send-email-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillin%2Fcloudflare-send-email-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillin%2Fcloudflare-send-email-service/lists"}