A few months ago I moved a site into EC2. I didn’t want to move the existing IMAP server (ugh) so I moved the email to Google Apps. There are only about 10 mailboxes so we went with “Standard” edition (free). Once we completed the move to EC2 we discovered that emails from our webserver were bouncing due to our EC2 IP address being listed in a spam RBL. This sucked, so I looked into relaying the mail from the EC2 webserver through our Google Apps account. Fortunately this turned out to be pretty easy.
This wiki page on scalix.com has a procedure for setting up SMTP relaying in Ubuntu with TLS & auth. I’m not running Ubuntu so the paths were different but it was basically the same procedure:
Create the file /etc/mail/client-info with these contents:AuthInfo:smtp.gmail.com "U:firstname.lastname@example.org" "I:email@example.com" "P:superpassword", where “example.com” is your Google Apps domain, “bounces” is a valid account, and the password is the account’s password. Mail relayed with these credentials will show “firstname.lastname@example.org” in the From: field of the message.
In /etc/mail, run makemap hash client-info < client-info
Edit /etc/mail/sendmail.mc, adding or uncommenting these lines:
Recompile sendmail.cf: m4 sendmail.mc > sendmail.cf . I got this error: "/etc/mail/sendmail.mc:10: m4: Cannot open /usr/share/sendmail-cf/m4/cf.m4" when running the command, but I resolved it by doing yum install sendmail-cf
Once this was done I sent myself a test message from the command line and received it; I checked the SMTP headers and sure enough it went through Google's mail server. One nice side effect is that all the mail sent by the webserver appears in the "Sent" folder for the Google Apps username provided in the client-info file. Hopefully this will resolve the spam issues, since the mail is now coming from Google's IP block.