如何在发送电子邮件时在 Amazon SES 中添加自定义 headers 或元数据......?

How can I add custom headers or metadata in Amazon SES while sending emails..?

我想在通过 Amazon SES 发送电子邮件时添加一些自定义 headers。我想在通过 Amazon SNS 发出退回通知时获取那些 headers。那么如何在发送电子邮件时传递自定义消息 ID?

现在我正在尝试使用

SendEmailRequest().putCustomRequestHeader(String, String);

但我在 Amazon SNS 通知反弹 JSON 中没有收到此 headers。 想法?

两件事:

首先,您需要使用 RawMessage 添加自定义 header。您正在将 header 添加到 SES API 调用,而不是消息本身。有关此主题,请参阅 Amazon SES custom header List-Unsubscribe isn't working

另一个第二个问题,是 Amazon SES 最近添加了在因退回、投诉或退订响应而收到的通知中查看自定义 header 的功能。您必须为任何域明确启用此功能。

您可以在 blog announcement post from June 14, 2016 中阅读更多关于它们的信息。

The Amazon SES team is pleased to announce the addition of original email headers to the bounce, complaint, and delivery notifications SES provides through Amazon SNS.

We strive to make your email-sending process easier, and today we’re taking another step in that direction. Increasing your visibility into the feedback you receive from SES has always been a key focus for us. Starting today, the headers you pass to SES in your email-sending requests can be made available in your SNS notifications. Read on for answers to some common questions.

How do I enable this feature?

Use the Amazon SES console or API to configure the notification settings for an identity (email address or domain) and notification type (bounce, complaint, or delivery).

For example, to use the SES console to include the original headers for an identity's bounce notifications, you'd go to the notification settings for an identity and select Include original headers next to the bounce notification configuration:

After this feature is enabled, the notifications will contain the headers in both raw name/value format and in JSON format for commonly provided headers.

可以使用标签:

new SendEmailRequest().withTags(new MessageTag().withName("environment").withValue(appService.getActiveProfile().toString()))

您在活动中收到标签 JSON。

"tags": {
    "environment": [
        "qa"
    ],
    ...
}