I think it's worth bumping this thread for a howto on how to do it with Postfix.
Originally Posted by narke
It's because my host is running some web services such wiki and a forum, their abilities of sending out email to users is based on the fact that the host gets smtp.
This is fairly common for PHP apps, and there's a technical reason. It's because the Linux implementation of PHP's standard library sends mail through an MTA. See: php.net/mail
Originally Posted by granth
I looked at that, went very pale, and thought, f___ that I'm using Postfix.
Alan Hicks wrote the Postfix SlackBuild (on SBo) to use Dovecot SASL by default. Dovecot SASL isn't available when Postfix connects as a client, so you need to build Postfix to use Cyrus SASL instead. Fortunately, he made that easy:
First, a safety precaution:
cp /etc/postfix/main.cf /etc/postfix/main.cf.dist
You need to set postfix up so that it can find its own aliases. Edit /etc/postfix/main.cf and add:
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
Build the aliases database:
At this point, Postfix is already set up to send and deliver mail locally. Test it out.
In one terminal:
tail -f /var/log/maillog
And in another:
Now you're ready to set Postfix up to relay mail to GMail. Start by setting Postfix to only accept mail from the local machine, with the following setting in main.cf:
mynetworks_style = host
The main.cf settings for turning on security (when connecting as a client) and enabling support, specifically, for GMail's SMTP server, are the same as the ones on innumerable blogs, such as this one: Postfix: Configuring Gmail as Relay
relayhost = [smtp.gmail.com]:587
# use tls
# use sasl when authenticating to foreign SMTP servers
smtp_sasl_auth_enable = yes
# path to password map file
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# list of CAs to trust when verifying server certificate
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
# eliminates default security options which are imcompatible with gmail
Then you add your SMTP login credentials to /etc/postfix/sasl_passwd:
Tell Postfix to recognize the credentials, and restart it:
Fire up "mail" again, and send an email to a test address. It should arrive, and the maillog should show that it was routed through GMail.
Finally, set /etc/rc.d/rc.local to run Postfix on boot:
if [ -x /etc/rc.d/rc.postfix ]; then
And of course, imediately after writing that, I found out that it was better to just use ssmtp. Here's one blog entry on it: http://www.volcanic.co.uk/ruby-on-ra...-smtp-servers/