SNS 未能警告 SES 模板电子邮件中缺少变量

问题描述 投票:0回答:1

我有一封 SES 模板电子邮件,其中有一行看起来像这样:

<h6>Welcome {{usernamee}}</h6>

我的电子邮件从未被发送,我花了很长时间才发现我的模板中有一个拼写错误。

我正在使用 AWS SDK for Java 2.x(确切地说是版本 2.20.153),AWS 的响应返回 200 OK。

环顾四周,SNS 似乎应该在电子邮件渲染失败时告诉我。我有一个带有简单 lambda 的 SNS,它会告诉我电子邮件何时被退回或已成功发送,但从未出现渲染错误

拉姆达:

exports.handler = function(event, context) {
    var message = event.Records[0].Sns.Message;
    console.log('Message received from SNS:', message);
};

这是我的 SNS 的其余配置:

resource "aws_sns_topic" "ses_topic" {
  name = "ses-topic"
}

resource "aws_lambda_function" "ses_sns_notification_sender" {
  filename      = "lambdas/ses-sns-notification-sender.zip"
  function_name = "ses-sns-notification-sender"
  role          = aws_iam_role.iam_for_lambda.arn
  handler       = "ses-sns-notification-sender.handler"
  runtime       = "nodejs14.x"
}

resource "aws_sns_topic_subscription" "ses_sns_notification_sender_subscription" {
  topic_arn = aws_sns_topic.ses_topic.arn
  protocol  = "lambda"
  endpoint  = aws_lambda_function.ses_sns_notification_sender.arn
}

resource "aws_lambda_permission" "allow_sns" {
  statement_id  = "AllowExecutionFromSNS"
  action        = "lambda:InvokeFunction"
  function_name = aws_lambda_function.ses_sns_notification_sender.function_name
  principal     = "sns.amazonaws.com"
  source_arn    = aws_sns_topic.ses_topic.arn
}

resource "aws_ses_identity_notification_topic" "email_notification" {
  count                    = length(var.sns_notification_type) // ["Bounce", "Complaint", "Delivery"]
  topic_arn                = aws_sns_topic.ses_topic.arn
  notification_type        = var.sns_notification_type[count.index]
  identity                 = var.ses_identity
  include_original_headers = true
}
amazon-web-services amazon-sns amazon-ses
1个回答
0
投票

取自SES文档

如果您发送的电子邮件包含无效的个性化内容, Amazon SES 可能会接受该消息,但无法传送它。 因此,如果您打算发送个性化电子邮件,您应该 配置 Amazon SES 以发送渲染失败事件通知 通过亚马逊 SNS。当您收到渲染失败事件时 通知,您可以识别哪条消息包含无效内容 内容,解决问题,然后再次发送消息。

© www.soinside.com 2019 - 2024. All rights reserved.