arunmr1980 / aws-email-service

Email service using AWS Services
MIT License
0 stars 2 forks source link

Email suppression on hard bounces #3

Open arunmr1980 opened 2 years ago

arunmr1980 commented 2 years ago
Implement email suppression for hard bounces
- When hard bounce happens, we need to add that email to account level suppression list 

Resources

arunmr1980 commented 2 years ago

Implementation

  1. Setup SES bounce notifications using a SNS topic (https://aws.amazon.com/premiumsupport/knowledge-center/ses-bounce-notifications-sns/)
  2. Add a lambda trigger to the SNS topic that receive notifications
  3. Add the emails to account level suppression list (https://docs.aws.amazon.com/ses/latest/dg/sending-email-suppression-list.html)
arunmr1980 commented 2 years ago

Setting up SNS bounce notifications for SES

arunmr1980 commented 2 years ago

Test the bounce notifications using the Amazon SES mailbox simulator (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-simulator.html)

arunmr1980 commented 2 years ago

SNS to Lambda integration in SAM template :- Invoke failure

https://medium.com/build-succeeded/subscribe-an-aws-lambda-function-to-an-sns-topic-in-cloudformation-and-work-6997a0f0b59b

arunmr1980 commented 2 years ago

Successful response on sending email to suppression list

[INFO] 2022-04-19T05:45:41.527Z c7e36171-bb15-42ac-8b2f-ccb27b0f801a {'ResponseMetadata': {'RequestId': '5d16a70e-8711-4c88-af64-2ca267f08c65', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Tue, 19 Apr 2022 05:45:41 GMT', 'content-type': 'application/json', 'content-length': '2', 'connection': 'keep-alive', 'x-amzn-requestid': '5d16a70e-8711-4c88-af64-2ca267f08c65'}, 'RetryAttempts': 0}} | [INFO] 2022-04-19T05:45:41.527Z c7e36171-bb15-42ac-8b2f-ccb27b0f801a {'ResponseMetadata': {'RequestId': '5d16a70e-8711-4c88-af64-2ca267f08c65', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Tue, 19 Apr 2022 05:45:41 GMT', 'content-type': 'application/json', 'content-length': '2', 'connection': 'keep-alive', 'x-amzn-requestid': '5d16a70e-8711-4c88-af64-2ca267f08c65'}, 'RetryAttempts': 0}}

arunmr1980 commented 2 years ago

Does emails in in suppression list still result in bounce?

Yes, This seem to result in a bounce though it does not count against accounts bounce rate.

According to this knowledge center article, the following error message is supposed to show

"Amazon SES did not send the message to this address because it is on the suppression list for your account. For more information about removing addresses from the suppression list, see the Amazon SES Developer Guide at https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-email-suppression-list.html"

However this does not happen on testing. Documentation in other places seem to suggest that email to suppressed email ids is a successful send event. So an error is not expected.

Documentation regarding account level suppression list mention the following.

If you attempt to send a message to an address that's on your account-level suppression list, SES accepts the message, but doesn't send it.

Documentation regarding monitoring emails define send event as follows.

Send – The send request was successful and Amazon SES will attempt to deliver the message to the recipient’s mail server. (If account-level or global suppression is being used, SES will still count it as a send, but delivery is suppressed.)

boto3 documentation does not have a message field in its response.

Screen Shot 2022-04-26 at 5 37 07 PM