集成 AWS SES + AWS SNS
配置 Identities
通过 DKIM authentication 验证身份
配置 SNS Topic
创建 SNS Topic
-
登录 AWS 控制台,打开服务:SNS(Simple Notification Service)
-
点击左侧导航栏的 “Topics” → [Create topic]
-
选择:
- Type: Standard。 SES 配置 SNS 通知时,SNS Topic 的 Type 只能选 Standard,SES 不支持 FIFO topic
- Name: 比如
ses-events-prod
-
其他默认即可,点击 Create topic
添加订阅(Subscription)
-
打开刚才创建的 Topic,进入详情页
-
点击 “Create subscription”
-
填写:
- Protocol:
HTTPS - Endpoint: 你的 Webhook Worker 地址
例如
https://example.com/api/webhooks/aws-sns
- Protocol:
-
点击 Create subscription
⚠️ 注意: AWS 会立即向你的 Worker 发一条 JSON:
1 2 3 4{ "Type": "SubscriptionConfirmation", "SubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=ConfirmSubscription&..." }你的 Worker 必须访问这个
SubscribeURL(GET 一次),才能完成订阅确认。
配置 Configuration sets
创建个 Configuration set
配置 Event destinations
选择事件
Hard bounces Complaints Rejects Rendering failures Delivery delays 可选 Deliveries 可选
event destination
选择对应的 sns topic
在发送邮件时使用 Configuration Set
发送邮件时(Cloudflare Worker 调 SES API 时), 在 body 或参数中添加:
|
|
这样 SES 才会将该邮件的投递、退信、投诉等事件发给 SNS → Webhook Worker。
配置 AWS_SNS_TOPIC_ARN
在webhook中,配置 AWS_SNS_TOPIC_ARN 环境变量为你的 SNS Topic ARN。