AWS SNS bounce notifications not being delivered - ruby-on-rails

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.

Related

Bamboo Mailer & SES Failing to send an email to one specific user

I am working on a production server that sends roughly 1000 emails a day with almost no issues. There is a single email that always fails and I have been unable to send an email to this user through our system. The site is built with Elixir and uses the Bamboo Mailer, specifically the smtp_adapter but I believe this may be an issue with SES rather than our code or the Elixir libraries we are using.
The particular user always throws this error:
{{:nocatch, {:permanent_failure, "501 Invalid RCPT TO address provided\r\n"}},
From what I can tell the email address is valid and the customer has verified it as such and stated that emails have been sent and received to the user outside of our system.
I'm looking for some context on how SES determines what a valid RCPT TO address is and more generally how SES works to send emails. I haven't been able to find much on this issue from the SES docs.

Mandrill is ghosting accounts or am i incorrect - it says delivered however mandrill did not even tried to send emails

I am using free mandrill account and sending email via using template and API
When i send message it returns okay it is sent as status
However even after several days there is still no smtp events at mandrill interface and the email is not arrived
So i am 100% suree mandrill is ghosting accounts
Or there is something else that i do not know?
Thank you for answers
PS: At the beginning emails were arriving but after some point no smtp events and no emails ever arrived even though no error message parsed. Also when i send to non existing email no bounce message returned.
Also account reputation is 61 : excellent
Yes i believe mandrill certainly ghosting accounts
After trying with several accounts i am now sure of it
Even if you send to non existing gmail email, it says delivered in its interface
However it should have displayed hard bounced
So beware of their free service. I believe this is not an ethical way of working. People would think that their emails are arriving however they are ghosted and mandrill did not even try to send them and yet displays delivered
Have you check it on Mandrill account? It shows all the report at outbound tag. The reason is, a queued response in the Mandrill API is not the same as a queued response from a recipient server.
When you send a message through Mandrill, you first relay it to Mandrill, Mandrill processes it, and then Mandrill relays it to the recipient server. This all happens quite quickly, but the two relaying steps are separate and distinct. The KB article you've linked to is providing additional details on that last step, relaying to recipient servers, not a queued status for the Mandrill API.
There are a number of reasons the Mandrill API may respond with queued including if you've added attachments or if you're sending to a bunch of recipients in a single API call.
Without seeing the actual API call that's being made, it's hard to say why you're getting a queued response. But if you're using the sample messages/send API call, you'll want to remove all of the optional parameters that you're not actually setting. For example, the sample has fake attachments, and a subaccount specified. The attachment will cause the call to be processed async. The subaccount probably doesn't exist, and would then cause the call to fail. So if that's the case, try removing all of those optional params. If not, please provide the API call you're making with sensitive data redacted (API key, actual email addresses).

Emails not going from Mandrill to Gmail

I'm trying to send email from my app, emails seem to be going to mandrill correctly and there getting delivered, but I see nothing in my inbox.
I've even tried sending them through my domain and I'm still not getting them. I get them from my live website its using gmail but I want to switch
Using mxtoolbox.com I found
SMTP Reverse DNS Mismatch and
454 4.7.1 Relay access denied which could mean its been marked for spam?
It's sent through emails twice so I'm wondering if theres a time between emails sent or something.
When I was testing this I thought my emails where being dropped by gmail. I found that for some reason there was a very long lag going from Mandril to Gmail. I received all my tests about an hour after Mandril sent them. Hope this helps someone stuck like I was.
Found this question trying to diagnose my issue.
I am using Mandrill and found that sending emails from Mandrill to Gmail will take anywhere from 10 seconds to 15 minutes. Can't establish a reason why sometimes it takes longer.
Mandrill blocks certain domains from being the send address to prevent fraud, but as long as you're sending from an address you know exists to an address you know exists, you should be fine. Also, if that were the problem, the email would bounce rather than send. Also, some email services have policies that prevent you from doing things like sending an email to your address from your address from an external service. Based on that error message you provided, it could be something like that; I would check your provider's policies (and your spam folder).
Not an answer but if you look on your mandrill Outbound activity page and click on the green icon that says Delivered you should see that it says No smtp events.
I don't know why it doesn't send but this show that it hasn't sent.
Or should I say hasn't arrived where it was supposed to.
Update:
On further investigation I found out that the emails weren't sending because I was using my personal email address as the sender from_email: When I changed this to a more business sounding email address it worked. So make something up if you have to, like no-reply#nonsense.com

How to keep IP trust from email companies when developing in local/test

I am using sendgrid on my Rails app that I am beginning to build.
I am in test mode, mostly doing local stuff but I send many emails to check my process or email layout.
The email I use to receive the emails is on Gmail. I fear Gmail will see there are many emails everyday and never an answer and maybe that the CSS changes a lot, and maybe other factors gmail take into account to assess the trust level of an IP sending emails...
Do I risk Gmail to decrease the trust level of my sendgrid IP? (I don't have much choice during test mode I think)?
What could I do to avoid the IP trust getting hit?
You could use mailtrap to avoid polluting true email addresses. You may check emails sent from their web interface or manually forward them to your inbox.
You could use mailcatcher to catch and view your emails sent from localhost.
MailCatcher runs a super simple SMTP server which catches any message
sent to it to display in a web interface. Run mailcatcher, set your
favourite app to deliver to smtp://127.0.0.1:1025 instead of your
default SMTP server, then check out http://127.0.0.1:1080 to see the
mail that's arrived so far.
In order for you to use it:
gem install mailcatcher
mailcatcher
Go to http://localhost:1080/

Sending Email via ActionMailer::Base using SMTP, but sender should be another email-adress

i'm searching for a way to send emails with ruby on rails via actionMailer. The difficulty is, that i am sending the emails via gmail smtp. But i have to send them from different email-adresses (the customers have to be able to setup there own email adress, but i dont want to save the credentials).
Any Idea?
Thanks"!
you have to setup a mail server to send your mails for you and you just send the mail with the headers saying that it is from the person's email address. there are many mail servers, sendmail being one of the standards for a VPS. if you pick a service like heroku, they have mailing as an addon: http://addons.heroku.com/sendgrid

Resources