I do this with SSMTP. It acts as an SMTP server and proxies to a real SMTP server. On Unix (Ubuntu hardy in this case) it makes the system sendmail work properly.
If you're also on Ubuntu, run apt-get install ssmtp
to get it.
This is a sample config file based on mine.
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=aspmx.l.google.com
mailhub=smtp.gmail.com:587
# Where will the mail seem to come from?
rewriteDomain=example.com
# The full hostname
hostname=yourhostname.example.com
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
# should turn on SSL & auth to google's SMTP server
# TODO change this user
UseTLS=YES
UseSTARTTLS=YES
[email protected]
AuthPass=yourgooglepassword
You will want to add this to your environment.rb
or production/environment.rb
:
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.raise_delivery_errors = true