We do not provide SMTP email services from Engine Yard Cloud because the entire EC2 IP space is black-listed by many spam services.
Our recommendation is to get an account with one of the following providers:
- SendGrid
- Google Apps (for a small volume of email)
- AuthSMTP
- SMTP.com
After you have your account set up, take note of your username/password and come back to this page.
Note: If using AuthSMTP, go into the control panel and enable SSL access to your mail relay.
Steps to configure your instance
-
Edit
/etc/ssmtp/ssmtp.conf
(a config file for ssmtp sendmail) and make it look like the following:mailhub=mail.authsmtp.com:2525
mailhub=smtp.gmail.com:587 -- used for Google Apps -
Replace this with the hostname you want email to come from:
rewriteDomain=example.com
-
Set
FromLineOverride
to make the the From: use the from line from the envelope. The only exception is if no from line is given.FromLineOverride=YES
-
Use SSL/TLS to send secure messages to server:
UseSTARTTLS=YES
-
Make sure that this isn’t
UseTLS=YES
.SSL connection to host = Success, Cannot open mail.authsmtp.com:2525
If you’re getting errors like the one above then you have the wrong variable.
UseTLS
doesn’t work with authsmtp, onlyUseSTARTTLS
does. -
Add your own user/password here:
AuthUser=username
AuthPass=password
AuthMethod=DIGEST-MD5 #Comment this out if you are using gmail or google apps -
Set your action mailer setting in
RAILS_ROOT/config/environment.rb
(or an env specific env file if you prefer):config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = {:arguments => "-i"} -
Ensure permissions on the three files
/etc/ssmtp/ssmtp.conf
,/usr/sbin/ssmtp
,/usr/bin/sendmail
are properly set:$ sudo chmod +x /usr/sbin/ssmtp /usr/bin/sendmail
$ sudo chown deploy:deploy /etc/ssmtp/ssmtp.confWhere
deploy
is the name of your SSH user you logged into your instance with.
You should now be able to send email from your application via your SMTP relay.
If you have feedback or questions about this page, add a comment below. If you need help, submit a ticket with Engine Yard Support.
Great tutorial, straight forward and i liked the prior debugging :)
The following setting is vital for Rails3 application:
config.action_mailer.sendmail_settings = {
:arguments => '-i'
}
Hi Andrei,
Thanks for pointing that out. We'll ask our docs team to make a quick update to this entry as soon as they can. We appreciate the heads-up for any and all future readers!
Hi Andrei, Thanks again for your feedback. The doc has been updated; see step 7. kjm
This article says to edit /etc/ssmtp/ssmtp.conf. But isn't it better to modify a recipe and apply it? I'm afraid that without a recipe my edits will be lost if I stop and restart an instance, and also there will be a bunch of manual work to edit /etc/ssmtp/ssmtp.conf on each machine in an environment.
Or am I missing something?
David,
I would of thought the same, I have changed my chef script to also copy a config file under cookbooks/ssmtp/files/default/ssmtp.conf. Under cookbooks/ssmtp/recipes/default.rb I added the following under the if statement.
remote_file "/data/ssmtp/ssmtp.conf" do
owner node[:owner_name]
group node[:owner_name]
mode 0644
source "ssmtp.conf"
backup false
action :create
end
Hi David,
You are correct that while it is possible to modify the configuration directly, it is advisable to use a custom Chef recipe instead. If you need further assistance or clarification, then feel free to create a support ticket.
Jay, thanks for pointing this out!
Evan
Hi everybody, why Amazon SES (simple email service) is not listed here? Do you have a bad feedback? We do want to choose a provider for smtp and as Engine Yard runs on AWS we thought Amazon SES would be the natural choice. What is you point of view. Thanks a lot.
Is there a reason that Engine Yard recommends sending email through sSMTP instead of directly over SMTP? We have been using Sendgrid for a long time, but only recently started using their SMTP API (http://sendgrid.com/docs/API_Reference/SMTP_API/) so that we could take advantage of the ability to send many emails via a single email delivery. When sending to more than a few email addresses (it would happen when using the SMTP API to send to 25 recipients), Sendgrid would email to notify us that the JSON we had sent in the X-SMTPAPI header included invalid JSON. After setting Debug=YES in our ssmtp.conf, we were able to see that this header was being truncated. Switching Rails from using sendmail to using smtp so it can talk directly to Sendgrid solved the problem.
Hello YouDontNeedACRM,
We don't list Amazon SES because it wasn't available and also because it is not currently available through us at this time. We have had great luck with alternate providers like SendGrid or Mail Chimp.