11

I have a Java Lambda (RequestStreamHandler) that receives SES messages, but I'm having a tough time figuring-out where the "content" is.

The record's eventSource is aws:ses, there is no "content" attribute per the documentation. The simple text message

I've tried with & without SNS as the delivery, no difference.

I've also added an S3 rule to the Rule Set that is identical to the Lambda rule and S3 is receiving the entire message with content.

Thanks

Mike Summers
  • 2,139
  • 3
  • 27
  • 57
  • Where do you see that Lambda notifications have `content`? Docs suggest you need to fetch the content from S3 if you want it: *"The event object passed to your Lambda function will contain metadata pertaining to the inbound email event. You can also use the metadata to access the message content from your Amazon S3 bucket."* -- https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-lambda.html – Michael - sqlbot Mar 11 '18 at 02:02
  • @Michael-sqlbot[This](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-notifications-examples.html) and [this](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-notifications-contents.html) indicate that `content` should be on the Event. There's no indication elsewhere that S3 is required. – Mike Summers Mar 11 '18 at 02:57
  • That is only applicable to SNS in certain cases, and then only when the body is very small. https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-notifications.html – Michael - sqlbot Mar 11 '18 at 03:39
  • @Michael-sqlbot the body is less than 100 bytes, then entire SES message less than 6k. – Mike Summers Mar 11 '18 at 10:37

1 Answers1

15

I believe I have this figured-out, if any of the following is incorrect please let me know.

  1. SES Events sent directly to a Lambda via a Rule Set do not contain the original email content.
  2. Using a Rule Set to place the email on a SNS topic, and the Lambda subscribing to the topic, results in (assuming the message is 150kb or less)
    • A SNS Event with a message tag
    • The message tag is escaped json which is a SNS Event with a content tag
    • The content tag is a raw RFC 2045 message

It is counter-intuitive that a Lambda cannot access the email content directly from a SES Event, but that appears to be the case.

Mike Summers
  • 2,139
  • 3
  • 27
  • 57
  • Thanks, after two nights of debugging you've saved me a third one. With your hint, I've quickly found in the [docs](https://docs.aws.amazon.com/ses/latest/dg/receiving-email-action-lambda.html): __The data that Amazon SES passes to Lambda includes metadata about the message, as well as several email headers. However, it doesn't contain the body of the message.__ – madhead Dec 06 '22 at 00:54