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

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.

Related

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.

How do I alternate domains for sending emails for my app running on Heroku with Sengrid Add-on?

So we are running a rails app on Heroku with the Sengrid add-on (free plan so no whitelabeling) (let's call it magicapp) and in our action mailer we always set the from field to be "noreply#magicapp.com". We have seen some of our email go to spam and someone suggested to us to try to alternate our email domain to improve deliverability.
So my questions are as follows:
What verification and checking goes on at the receiver side to verify that the email really is sent from "magicapp" and not just someone pretending to be magicapp?
Right now, when we send an email from "noreply#magicapp.com" the email says it's from "noreply#magicapp.com via sendgrid.me" so when receiver clients are doing spam checking, do they use my "magicapp.com" domain for reputation or the "sengrid" domain?
If it does use the "magicapp.com" domain, could I just set my from field in my action mailer to be a different domain such as "magicapp-mail.com"? Are there any potential issues to this or additional things to set up, like DNS etc? If I do this, will the receiver use the reputation of the magicapp-mail domain instead of magicapp then?
Any answers or information would be much appreciated, thanks!
I am pretty sure setting sendgrid's DKIM and SPF records properly will save your emails from being sent to spam. At least that's what worked in my app I was working on and emails ended in inbox, unless users hit Mark as spam instead of unsubscribe.
DKIM
DKIM stands for DomainKeys Identified Mail which was designed to help ISPs prevent malicious email senders by validating email from specific domains.
What a basic DKIM record should look like:
smtpapi._domainkey.yourdomain.com. | TXT or CNAME | value
smtpapi._domainkey.subdomain.yourdomain.com. | TXT or CNAME | value
TXT value: k=rsa; t=s; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDPtW5iwpXVPiH5FzJ7Nrl8USzuY9zqqzjE0D1r04xDN6qwziDnmgcFNNfMewVKN2D1O+2J9N14hRprzByFwfQW76yojh54Xu3uSbQ3JP0A7k8o8GutRF8zbFUA8n0ZH2y0cIEjMliXY4W4LwPA7m4q0ObmvSjhd63O9d8z1XkUBwIDAQAB
CNAME value: dkim.sendgrid.net
docs: https://sendgrid.com/docs/Glossary/dkim.html
SPF
Sender Policy Framework (SPF) is an email authentication standard developed by AOL that compares the email sender’s actual IP address to a list of IP addresses authorized to send mail from that domain. The IP list is published in the domain’s DNS record.
The DNS record should look like this:
yourdomain.com. | TXT | v=spf1 a mx include:sendgrid.net ~all
docs: https://sendgrid.com/docs/Glossary/spf.html
The key is your 2nd question. As long as you're not whitelabeled, the receiving server 'knows' the mail came from SendGrid, so it checks SendGrid for all DKIM & SPF records. SendGrid signs your mail with their own DKIM if you're not whitelabeled, so it all checks through.
"Alternating" the domain does not sound like a feasible way to avoid bulking of your mail. We're still in an IPv4 world, and IPs are still the main source of reputation tracking in the email world. No matter what domain your mail says it's "From", the receiving server knows what IPs gave it the mail (unless your domain is so bad it's blacklisted).
What does mail-tester.com say about your mail?

Sending email using smtp gmail server from Amazon EC2 instance

I have a gmail for business emailId and would like to use it for sending out messages to my clients. I am using smtp.gmail.com to send out messages from an asp.net mvc application. This works fine on my localhost. But when I deployed the code to Amazon EC2, the functionality broke. I searched and found that EC2 IPs are blackisted by google. How should I fix this? I read that one way is to use Amazon SES, but can anyone tell how does it work? Is it just a verification policy enforcement thing and does it support sending out email from the said gmail account? Is there any other workaround?
Edit 1: As suggested I have contacted Amazon to provide production access. It is in process.
Meanwhile, I am seeing that I am able to send mails from my application. These are my settings -
WebMail.SmtpServer = "smtp.gmail.com";
WebMail.SmtpPort = 587;
WebMail.EnableSsl = true;
WebMail.UserName = "me#example.com";
WebMail.From = "me#example.com";
WebMail.Password = "MyPassword";
WebMail.SmtpUseDefaultCredentials = false;
Is there a reason why suddenly it is working. Is this intermittent or can I move on to using this as such?
SES is the solution for this problem, and then good thing is, unless you are sending 10's of thousands of emails it will only cost you pennies to do - it will allow you to send an email, and make it come from (or appear to come from) your gmail account.
First step is to verify to SES that you own/control the email address you want to send from - that can be done by clicking on a link in an email they send to that address, or else adding some TXT entries to your DNS settings. If you control the domain, I prefer to use the DNS method so that I can verify the entire domain for sending emails, not just the one account - then you can do things like send from 'sales#mydomain.com', 'billing#mydomain.com' etc w/out having to verify each email address individually.
Once you account is verified, sending email from SES using the SMTP option is exactly the same as sending it thru any other SMTP server - use the SMTP server name, username and password from amazon, and away you go.
Very easy, very inexpensive and emails are sent very fast.
Be aware there are limits by default - I believe 5/second and 10,000/month by default - but that can be upped if you have a legitimate need.
Also, once your account is setup with SES, you are not limited to sending your emails just from EC2 instance, you can use it anywhere - for example my outlook email, my mac and my iphone all use SES as my SMTP provider.
I was actually able to send an email using an EC2 instance. Try editing your SMTP Server to ssl://smtp.gmail.com

Sending email to the "outside world" from localhost using hMailServer and Gmail SMTP on Windows 7

I am not sure if this is technically possible but I am running a AMPPS box on Windows 7 as my localhost and I have configured it with Gmail SMTP (ssl://smtp.gmail.com) to send out email from my PHP scripts like joomla, wordpress, socialengine, etc.
Now I installed and setup hMailServer and I am able to send and receive emails locally but was wondering if there was a simple way that I could configure my localhost and email server to send out email to outside world (e.g. #hotmail.com or #yahoo.com receipients) using Gmail SMTP?
Currently with my setup, I am only able to receive installation confirmation emails from AMPPS but nothing else like "Forget Password" or "User Registration Forms" work.
Any ideas without getting too deep into code modification?
The simple answer is no, or rather it is far from easy, especially from a home based server.
And the reason is that your IP address amd mail server domain will not be considered as a ligitimate mail server by most of the legitimate mailservers you will be trying to send mail to, and they will just reject it as yet another spam server.
Have a look at these:
https://serverfault.com/questions/72559/setting-up-a-mail-server-best-practices-to-be-recognized-as-legitimate
How to conduct legitimate email campaigns

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