Skip to content

非公式本サイトは非公式の日本語ドキュメントであり、Cloudflare 公式サイトではありません。最新情報はdevelopers.cloudflare.comをご確認ください。

送信バインディングを設定する

最終更新 Markdown で表示Agent セットアップ

Worker に send_email バインディングを追加すると、送信元と宛先に使えるアドレスを制限できます。制限は Wrangler 設定ファイルで行います。バインディング API 自体については Workers API を参照してください。

バインディングの種類

send_email の各エントリで、バインディングの動作を制限できます。送信元アドレスは、必ず Email Service に追加済みのドメインに属する必要があります。

  • 制限属性なし: アカウント内の検証済み宛先アドレスなら、どこへでも送信できます。
  • destination_address: ここで設定した宛先アドレスにだけ送信できます。send()tonull または 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 からメールを送信します。
  • ドメイン設定 — 送信元ドメインを追加します。

役に立ちましたか?