SES -> SNS -> SQS -> Lambda -> DynamoDB

AWS

概要

  • AWS SESを使いだすのは簡単ですが、エラーメールや、クレーム、バウンスなどを適切に処理しないとSES上のエラーレートが上がってしまうので対策をする設定です。
  • このあたりを参考にしながら

以下は、スクリーンショットをメインに適当にメモ書きです

const AWS = require('aws-sdk');
const documentClient = new AWS.DynamoDB.DocumentClient();

exports.handler = async (event, context, callback) => {

  const tableName = 'ses_complaint';

  // event["Records"][0]["ses"]["mail"]["commonHeaders"]["messageId"];
  var message_id = (new Date).getTime().toString();

  Object.assign(event, { id: message_id });

  var params = {
    TableName: tableName,
    Item: event
  };

  await documentClient.put(params).promise();
};

aws --profile minedia --region us-east-1 ses send-email \
  --to [email protected] --from [email protected] \
  --subject "complaint" \
  --text "ses mail complaint body"

aws --profile minedia --region us-east-1 ses send-email \
  --to [email protected] --from [email protected] \
  --subject "bounce" \
  --text "ses mail bounce body"

aws --profile minedia --region us-east-1 ses send-email \
  --to [email protected] --from [email protected] \
  --subject "success" \
  --text "ses mail bounce body"

Comments

Copied title and URL