跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com

发送绑定

最后更新 查看 MarkdownAgent 设置

向 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]" ]

后续步骤

这篇文档对您有帮助吗?