neurotrigger

Setup postfix as a gmail relay

by mmnicolas on Jul.27, 2009, under gnu/linux

Here’s how to use postfix to send mail through gmail. Assuming you have postfix and libsasl2-modules installed, the rest should be automatically installed since it depends on it. First open your postfix main.cf file located at /etc/postfix/ (on debian).

Append this to the end:

relayhost= [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous

smtp_destination_rate_delay = 60
relay_destination_rate_delay = 60

mailbox_command = /usr/bin/procmail -a $EXTENSION

The two paths you see above, /usr/bin/ & /etc/postfix will remain the same on almost any GNU/Linux distro, if you want to set this up on FreeBSD, it will be /usr/local/bin & /usr/local/etc/ respectively.

Next, create the sasl_passwd file in the /etc/postfix directory, insert the following:

[smtp.gmail.com]:587 USERNAME@gmail.com:CLEAR_TEXT_PASSWORD

Replace the two highercase variables with your own, save and quit.

Then type this to hash the file so it could be used by postfix:

postmap hash:sasl_passwd

This will result in a sasl_passwd.db, this is what hash:/etc/postfix/sasl_passwd refers to.

Restart postfix:

./etc/init.d/postfix restart

The final step is to test if it works well, to do so fire up mutt or your preferred mail client and send a mail.

You will notice there is some warning messages in /var/log/mail.log, don’t worry about them:

certificate verification failed for smtp.gmail.com[XXX.XXX.XXX.XXX]:587: untrusted issuer /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium Server CA/emailAddress=premium-server@thawte.com

The fact you dont *fully* trust google doesnt mean you can’t send mail through them.

Share this post:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • LinkedIn
  • PDF
  • StumbleUpon
  • Twitter
:, , , , , ,

Leave a Reply

Looking for something?

Use the form below to search the site:

Visit my idols!

Those who gave us tools to play with...

    Archives

    All entries, chronologically...