mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-07-12 16:02:10 +08:00
feat(subdomain): add random second-level mailbox support (#924)
Summary: add random second-level subdomain mailbox creation for web, admin, and Telegram. Scope: worker config, UI toggle, and README/VitePress documentation. Co-authored-by: wufei <fwu@creams.io>
This commit is contained in:
@@ -9,3 +9,29 @@ Mail channel is no longer supported. The reference below is limited to the recei
|
||||
Reference
|
||||
|
||||
- [Configure Subdomain Email](https://github.com/dreamhunter2333/cloudflare_temp_email/issues/164#issuecomment-2082612710)
|
||||
|
||||
## Create Random Second-level Subdomain Addresses
|
||||
|
||||
If your base domain mail routing is already configured, you can also let users create mailbox
|
||||
addresses with an automatically generated random second-level subdomain, for example:
|
||||
|
||||
- Base domain: `abc.com`
|
||||
- Created address: `name@x7k2p9q1.abc.com`
|
||||
|
||||
This is useful for mailbox isolation and reducing repeated hits on the same address.
|
||||
|
||||
Add these worker variables:
|
||||
|
||||
```toml
|
||||
RANDOM_SUBDOMAIN_DOMAINS = ["abc.com"]
|
||||
RANDOM_SUBDOMAIN_LENGTH = 8
|
||||
```
|
||||
|
||||
- `RANDOM_SUBDOMAIN_DOMAINS`: base domains that allow optional random second-level subdomains
|
||||
- `RANDOM_SUBDOMAIN_LENGTH`: random string length, range `1-63`, default `8`
|
||||
|
||||
> [!NOTE]
|
||||
> This feature only appends a random second-level subdomain when the mailbox is created.
|
||||
>
|
||||
> It does not automatically create Cloudflare-side subdomain mail routes or DNS records for you,
|
||||
> so make sure the base-domain/subdomain routing is already available first.
|
||||
|
||||
@@ -32,11 +32,20 @@
|
||||
| `ADDRESS_REGEX` | Text | Regular expression to replace illegal symbols in `email address` name, symbols not in the regex will be replaced. Default is `[^a-z0-9]` if not set. Use with caution as some symbols may prevent email reception | `[^a-z0-9]` |
|
||||
| `DEFAULT_DOMAINS` | JSON | Default domains available to users (not logged in or users without assigned roles) | `["awsl.uk", "dreamhunter2333.xyz"]` |
|
||||
| `CREATE_ADDRESS_DEFAULT_DOMAIN_FIRST` | Text/JSON | Whether to prioritize default domain when creating new addresses, if set to true, will use the first domain when no domain is specified, mainly for telegram bot scenarios | `false` |
|
||||
| `RANDOM_SUBDOMAIN_DOMAINS` | JSON | Base domains that allow optional random subdomain creation, so `name@abc.com` can become `name@<random>.abc.com` | `["abc.com"]` |
|
||||
| `RANDOM_SUBDOMAIN_LENGTH` | Number | Random subdomain length, default `8`, valid range `1-63` | `8` |
|
||||
| `DOMAIN_LABELS` | JSON | For Chinese domains, you can use DOMAIN_LABELS to display Chinese names | `["中文.awsl.uk", "dreamhunter2333.xyz"]` |
|
||||
| `ENABLE_AUTO_REPLY` | Text/JSON | Allow automatic email replies. Sender filter (`source_prefix`) supports three modes: empty to match all senders, prefix for `startsWith` matching, or `/regex/` syntax for regex matching (e.g. `/@example\.com$/`) | `true` |
|
||||
| `DEFAULT_SEND_BALANCE` | Text/JSON | Default email sending balance, will be 0 if not set | `1` |
|
||||
| `ENABLE_ADDRESS_PASSWORD` | Text/JSON | Enable address password feature, when enabled, passwords will be auto-generated for new addresses, supports password login and modification | `true` |
|
||||
|
||||
> [!NOTE]
|
||||
> `RANDOM_SUBDOMAIN_DOMAINS` only controls automatic random subdomain generation during mailbox
|
||||
> creation. It does not create Cloudflare-side subdomain routing for you.
|
||||
>
|
||||
> Subdomain addresses are usually best used for receiving only; for sending, prefer the main
|
||||
> domain.
|
||||
|
||||
## Email Reception Related Variables
|
||||
|
||||
| Variable Name | Type | Description | Example |
|
||||
|
||||
@@ -9,3 +9,27 @@ mail channel 已不被支持,下面参考中仅限收件部分。
|
||||
参考
|
||||
|
||||
- [配置子域名邮箱](https://github.com/dreamhunter2333/cloudflare_temp_email/issues/164#issuecomment-2082612710)
|
||||
|
||||
## 创建随机二级域名地址
|
||||
|
||||
如果你已经配置好了基础域名的收件路由,还可以让用户在创建邮箱时,自动生成随机二级域名地址,例如:
|
||||
|
||||
- 基础域名:`abc.com`
|
||||
- 创建结果:`name@x7k2p9q1.abc.com`
|
||||
|
||||
这适合做收件隔离、降低地址被重复命中的概率。
|
||||
|
||||
在 `worker` 变量中增加:
|
||||
|
||||
```toml
|
||||
RANDOM_SUBDOMAIN_DOMAINS = ["abc.com"]
|
||||
RANDOM_SUBDOMAIN_LENGTH = 8
|
||||
```
|
||||
|
||||
- `RANDOM_SUBDOMAIN_DOMAINS`:允许启用随机二级域名的基础域名列表
|
||||
- `RANDOM_SUBDOMAIN_LENGTH`:随机串长度,范围 `1-63`,默认 `8`
|
||||
|
||||
> [!NOTE]
|
||||
> 这个功能只是在“创建地址”时自动补一个随机二级域名。
|
||||
>
|
||||
> 它不会自动帮你创建 Cloudflare 侧的子域名收件路由或 DNS 配置,请先确保基础域名/子域名路由本身已经可用。
|
||||
|
||||
@@ -32,11 +32,19 @@
|
||||
| `ADDRESS_REGEX` | 文本 | `邮箱名称` 替换非法符号的正则表达式, 不在其中的符号将被替换,如果不设置,默认为 `[^a-z0-9]`, 需谨慎使用, 有些符号可能导致无法收件 | `[^a-z0-9]` |
|
||||
| `DEFAULT_DOMAINS` | JSON | 默认用户可用的域名(未登录或未分配角色的用户) | `["awsl.uk", "dreamhunter2333.xyz"]` |
|
||||
| `CREATE_ADDRESS_DEFAULT_DOMAIN_FIRST` | 文本/JSON | 创建新地址时是否优先使用默认域名,如果设置为 true,当未指定域名时将使用第一个域名, 主要用于 telegram bot 场景 | `false` |
|
||||
| `RANDOM_SUBDOMAIN_DOMAINS` | JSON | 允许启用随机子域名的基础域名列表,启用后可把 `name@abc.com` 创建成 `name@随机串.abc.com` | `["abc.com"]` |
|
||||
| `RANDOM_SUBDOMAIN_LENGTH` | 数字 | 随机子域名长度,默认 `8`,范围 `1-63` | `8` |
|
||||
| `DOMAIN_LABELS` | JSON | 对于中文域名,可以使用 DOMAIN_LABELS 显示域名的中文展示名称 | `["中文.awsl.uk", "dreamhunter2333.xyz"]` |
|
||||
| `ENABLE_AUTO_REPLY` | 文本/JSON | 允许自动回复邮件。发件人过滤(`source_prefix`)支持三种模式:留空匹配所有发件人、填写前缀进行 `startsWith` 匹配、使用 `/regex/` 语法进行正则匹配(如 `/@example\.com$/`) | `true` |
|
||||
| `DEFAULT_SEND_BALANCE` | 文本/JSON | 默认发送邮件余额,如果不设置,将为 0 | `1` |
|
||||
| `ENABLE_ADDRESS_PASSWORD` | 文本/JSON | 启用邮箱地址密码功能,启用后创建新地址时会自动生成密码,并支持密码登录和修改 | `true` |
|
||||
|
||||
> [!NOTE]
|
||||
> `RANDOM_SUBDOMAIN_DOMAINS` 只负责“创建地址时自动补随机子域名”,不会自动帮你创建 Cloudflare
|
||||
> 侧的子域名路由。
|
||||
>
|
||||
> 子域名地址通常更适合收件;如果要发件,仍建议优先使用主域名。
|
||||
|
||||
## 接受邮件相关变量
|
||||
|
||||
| 变量名 | 类型 | 说明 | 示例 |
|
||||
|
||||
Reference in New Issue
Block a user