跳转到内容
搜索文档

配置发送绑定

最后更新 查看 MarkdownAgent 设置

向 Worker 添加 send_email 绑定时,你可以限制其可从哪些地址发送、以及可发送到哪些地址。在 Wrangler 配置文件中配置这些限制。有关绑定 API 本身,请参阅 Workers API

绑定类型

send_email 中的每一项都可配置为限制绑定的能力。发件人地址必须始终属于你已加入 Email Service 的域名。

  • 无限制属性:绑定可发送到账户中任何已验证的目标地址。
  • destination_address:绑定只能发送到此处配置的单个目标地址。如果调用 send() 时将 to 设为 nullundefined,则使用该配置地址。
  • 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": "ops@yourdomain.com",
		},
		// Send only to addresses on an allowlist
		{
			"name": "EMAIL_TEAM",
			"allowed_destination_addresses": [
				"alice@yourdomain.com",
				"bob@yourdomain.com",
			],
		},
		// Send only from addresses on an allowlist
		{
			"name": "RESTRICTED_EMAIL",
			"allowed_sender_addresses": [
				"noreply@yourdomain.com",
				"support@yourdomain.com",
			],
		},
	],
}
[[send_email]]
name = "EMAIL"

[[send_email]]
name = "NOTIFY_OPS"
destination_address = "ops@yourdomain.com"

[[send_email]]
name = "EMAIL_TEAM"
allowed_destination_addresses = [ "alice@yourdomain.com", "bob@yourdomain.com" ]

[[send_email]]
name = "RESTRICTED_EMAIL"
allowed_sender_addresses = [ "noreply@yourdomain.com", "support@yourdomain.com" ]

后续步骤

这篇文档对您有帮助吗?