Sending email with AWS SES without custom domain - ruby-on-rails

I would like to send email from a Rails 5.1 app with AWS SES through smtp, but without using a custom domain (it's ok if users receive emails with an address from aws). But when searching through AWS documentation or google, I can only find instructions to use custom domains.
Is it possible? And if yes, what email address (mail FROM) should be used to replace the placeholder in config/initializers/devise.rb:
config.mailer_sender = 'please-change-me-at-config-initializers-devise#example.com'
?

You don't need to have a custom domain, but you do need to have at least an email address you can verify following the procedure outlined in https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html
AWS doesn't have "default" email addresses to use for sending mails. Note also, that SES require you to handle bounces and such.

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.

Subdomains in Mandrill

I am using Mandrill trial account for sending emails, i have a question which i am not able to find a solution.
I have a domain (www.domain.com) which is registered with Mandrill account with an email address email1#domain.com. I have a requirement where i have to sent emails from different sub domains from mandrill. Is there any facility to configure sub domains or wildcard DNS in Mandrill. Basically i want to sent email from different email addresses like email1#subdomain1.domain.com, email2#subdomain2.domain.com, email3#subdomain3.domain.com.
Here the sub domains can be anything which changes for different users, but the main domain doesn't change. Is there ant way to achieve this.
Please help me, I am new to Mandrill.
Since you own the domain and thus also the email server,
go to your email settings
forward/reroute email2#subdomain2.domain.com to email2#domain.com
receive verification link on email2#domain.com
verify and use the application

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

DKIM signatures to Rails application using Amazon SES

We're using the ActionMailer with SMTP as our delivery method and Amazon SES as our outgoing mail provider.
We want to sign the emails with DKIM.
How can we do that?
Thanks
I haven't used DomainKeys Identified Mail (DKIM) via ActionMailer with Amazon SES myself yet, but here's how I'd approach it:
Review Authenticating Email with DKIM and take note of the closing note specifically:
Note
If you are using the Amazon SES SMTP interface to send email, and
your client software automatically performs DKIM signing, you should
check to ensure that your client does not sign any of the headers
listed above. We recommend that you check the documentation for your
software to find out exactly what headers are signed with DKIM.
Checkout John Hawthorn's DKIM signing library (see his Introducing the dkim gem as well); section Usage With Rails shows how to sign all ActionMailer deliveries:
# Configure dkim globally (see above)
Dkim::domain = 'example.com'
Dkim::selector = 'mail'
Dkim::private_key = open('private.pem').read
# UPDATE [John Hawthorn]: SES developer guide recommends against signing these
Dkim::signable_headers = Dkim::DefaultHeaders - \
%w{Message-ID Resent-Message-ID Date Return-Path Bounces-To}
# This will sign all ActionMailer deliveries
ActionMailer::Base.register_interceptor('Dkim::Interceptor')
Update
John Hawthorn has updated the code fragment with the required SES exceptions (see respectively commented line above), confirming that his apparently excellent dkim gem is indeed
If the mentioned SES/DKIM header exception requirements can be met by the dkim gem,this looks like a remarkable easy way to achieve your goal - thanks John!
You can use the dkim project to do that for you :
https://github.com/jhawthorn/dkim
You can take it completely out of your source code and let SES do the DKIM signing for you. Works great.
https://aws.amazon.com/blogs/aws/simple-email-service-easy-domainkeys-identified-mail-support/

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