向 Worker 添加 send_email 绑定时,你可以限制其可从哪些地址发送、以及可发送到哪些地址。在 Wrangler 配置文件中配置这些限制。有关绑定 API 本身,请参阅 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]" ]- Workers API — 使用绑定从 Worker 发送邮件。
- 域名配置 — 接入你用于发送的域名。