向 Worker 添加 send_email 绑定时,可以限制其发件人和收件人地址。以下 Wrangler 配置变体会应用这些限制。有关绑定 API,请参阅 Email Sending Workers API。
每个 send_email 条目支持一种不同的限制选择。发件人地址必须属于已接入的 Email Service 域。
- 无限制属性:绑定可发送到账户中任何已验证的目标地址。
destination_address:绑定只能发送到此处配置的单个目标地址。如果调用send()时将to设为null或undefined,则使用该配置地址。allowed_destination_addresses:绑定只能发送到此允许列表中的地址。allowed_sender_addresses:绑定只能从该允许列表中的地址发送。
{
"send_email": [
// Send to any verified destination
{ "name": "EMAIL" },
// Send only to a single fixed destination
{
"name": "NOTIFY_OPS",
"destination_address": "[email protected]",
},
// Send only to addresses on an allowlist
{
"name": "EMAIL_TEAM",
"allowed_destination_addresses": [
"[email protected]",
"[email protected]",
],
},
// Send only from addresses on an allowlist
{
"name": "RESTRICTED_EMAIL",
"allowed_sender_addresses": [
"[email protected]",
"[email protected]",
],
},
],
}[[send_email]]
name = "EMAIL"
[[send_email]]
name = "NOTIFY_OPS"
destination_address = "[email protected]"
[[send_email]]
name = "EMAIL_TEAM"
allowed_destination_addresses = [ "[email protected]", "[email protected]" ]
[[send_email]]
name = "RESTRICTED_EMAIL"
allowed_sender_addresses = [ "[email protected]", "[email protected]" ]- Email Sending Workers API — 使用绑定从 Worker 发送电子邮件。
- 域名配置 — 接入你用于发送的域名。