简体   繁体   中英

AWS SNS bounce notifications not being delivered

I have a Rails 4.2 app that's hosted on AWS that uses SES to deliver emails. I've set up SNS to POST notifications to the app when an email bounces. If I send a test email via the SES console, the endpoint associated with the SNS subscription gets hit by AWS exactly as expected with the bounce notification. When an email that gets sent from the application itself bounces, the endpoint is not hit, though there appears to be a corresponding bounce in the email statistics shown in the SES console.

If an email gets sent from the app with a Return-Path , the email associated with the return path does receive a "Delivery Status Notification (Failure)" message from the SES mailer daemon (though that email does go to spam). I have also checked the Apache access_log and error_log and only see the bounce notification endpoint hit when emails are sent via the SES console.

The emails within the app are sent via ActionMailer with a delivery_strategy of :aws_sdk (provided by the aws-sdk-rails gem). I have also tried using a delivery strategy of :smtp with email-smtp.us-east-1.amazonaws.com and the SES credentials--the only differences between the two strategies is that the :smtp strategy fails to follow the Return-Path . The Domain and email used in the "From" address are both verified with AWS, and DKIM is enabled, verified and appears to be working. The Bounce Notifications SNS Topic for the Domain is the correct one (and the topic's subscription has already been confirmed).

I've tested delivering emails to addresses with non-existent domains, non-existent addresses with real domains and bounce@simulator.amazonses.com . All tests with the app result in nothing being POSTed to the notification endpoint, and all tests with the SES console result in the expected behavior. All Amazon services use the same region (us-east-1), and all emails that are expected to be delivered without bouncing get delivered appropriately.

The code that delivers the mail looks essentially like this:

class SomeMailer < ApplicationMailer
  def some_email
    ...
    mail(
      to: destination,
      from: sender,
      cc: cc_addresses,
      subject: some_subject,
      template_name: some_template,
      return_path: return_path_email
    )
  end
end

I've tried taking out the return_path which has no effect on the SNS endpoint being hit.

I've done quite a bit of searching here and in the AWS docs and haven't found anything that changes this behavior. Any tips on how to get the bounce notifications delivered when being sent by the app would be greatly appreciated.

If you are using a Simple Mail Service verified email address to send the emails then make sure your notification topic is configured for that email address. If it is only configured for your domain then it will not work.

I ran into the same problem you describe and it was because I only had the notifications configured on my domain name and not the email address.

It's late but will surely help others, I was facing the same problem than realized that I was missing the configuration set header when I was sending an email from my web app. I got to know this through SES sent test mail screen where there is a configuration set header. Aws SES sent test email screen So by adding this header you will start receiving the notifications.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM