Skip to content
helloxzPublic

About

A Cloudflare Workers email gateway with multi-SMTP support and a unified HTTP sending API.

Topics

Resources

Stars

26 stars

Watchers

0 watching

Forks

Repository files navigation

ZSend

中文文档

ZSend is an email sending gateway deployed on Cloudflare Workers. It provides a Web admin panel, multiple SMTP account management, and a unified HTTP email sending API.

Features

  • Supports deployment on Cloudflare Workers
  • Visual management: manage SMTP accounts and view email sending logs through the Web UI
  • Supports configuring multiple SMTP accounts
  • Provides a unified HTTP API for sending emails
  • Supports text, html, and markdown content
  • Automatic retry: retries once when SMTP sending fails
  • Sending logs: records a log for every email sending request, including which API key was used
  • Authenticated access: the admin panel uses username/password login; the send endpoint is protected with API keys

Screenshots

CleanShot 2026-05-29 at 08.08.59@2x.png

CleanShot 2026-05-29 at 08.11.38@2x.png

Deploy to Cloudflare Workers

Prerequisites

  1. Install Wrangler CLI
  2. Log in to your Cloudflare account
  3. Install Bun
wrangler login

1. Fork and Clone the Project

Fork this project to your GitHub account, then clone it locally:

git clone https://github.com/your-username/zsend.git
cd zsend

2. Create a D1 Database

wrangler d1 create zsend

After creation, you will see output similar to:

✅ Successfully created DB 'zsend'
[[d1_databases]]
binding = "DB"
database_name = "zsend"
database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

Copy the generated database_id into the database_id field in wrangler.jsonc.

3. Set Environment Variables

# Admin login username
wrangler secret put ADMIN_USERNAME

# Admin login password
wrangler secret put ADMIN_PASSWORD

ADMIN_USERNAME and ADMIN_PASSWORD are used for the Web admin login. To change the password later, update the secret and redeploy.

API keys for POST /api/v1/send are created in the Web UI (API Keys page), not with environment variables.

4. Deploy the Project

bun install
wrangler deploy

After deployment succeeds, the access URL will be displayed, for example: https://zsend.your-subdomain.workers.dev

5. Configure SMTP Accounts

After deployment, visit https://zsend.your-subdomain.workers.dev, log in with your admin username and password, then configure SMTP accounts and create API keys through the Web UI.

6. Test Sending

Create an API key on the API Keys page, then use it as the Bearer token:

curl -X POST "https://zsend.your-subdomain.workers.dev/api/v1/send" \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "no-reply@example.com",
    "to": "user@example.com",
    "title": "Welcome",
    "content": "# Hello\nThis is an email sent by ZSend.",
    "type": "markdown",
    "sender_name": "ZSend Notifications"
  }'

Send Email

POST /api/v1/send
Authorization: Bearer <API_KEY>
Content-Type: application/json

Request body example:

{
  "from": "no-reply@example.com",
  "to": "user@example.com",
  "title": "Welcome",
  "content": "# Hello\nThis is an email sent by ZSend.",
  "type": "markdown",
  "sender_name": "ZSend Notifications"
}

Field reference:

  • from: required, sender email address
  • to: required, recipient email address; can be a string or an array, for example: ["user1@example.com", "user2@example.com"]
  • title: required, email subject
  • content: required, email body
  • type: optional, only text, html, and markdown are supported; default is text
  • sender_name: optional, display name for the sender in this request; overrides the default value in the configuration

curl example:

curl -X POST "http://127.0.0.1:8000/api/v1/send" \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "no-reply@example.com",
    "to": "user@example.com",
    "title": "Welcome",
    "content": "# Hello\nThis is an email sent by ZSend.",
    "type": "markdown",
    "sender_name": "ZSend Notifications"
  }'

About

A Cloudflare Workers email gateway with multi-SMTP support and a unified HTTP sending API.

Topics

Resources

Stars

26 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages