Use Postfix as Local SMTP Mac OS X

Written by
Date: 2012-03-16 21:11:00 00:00


As I'm constantly trying and changing my default email application on my Mac, I'm currently using Thunderbird, the native email application and also Pilot.

So, decided to use my own local SMTP in order to not store my credentials on each application, and for an easy configuration. Also because I like emails to go fast from y outbox. Then it will be Postfix responsibility to deliver the email properly.

The problem is that my laptop is constantly changing its IP, so most of my emails will not get its destinations if I try to deliver them directly from the Macbook.

What I did, was to configure postfix to relay on Gmail to deliver my emails.

Instalation

There is nothing to install postfix is already installed on my Mac.

Configuration

First things first, let's create a file to store our credentials.

sudo vim /etc/postfix/sasl_passwd

Then add inside something like this:

smtp.gmail.com:587 username@gmail.com:password

If you are using Google Apps, replace gmail.com for your own domain.

Now run:

sudo postmap /etc/postfix/sasl_passwd

And finally prepare the postfix main configuration file.

sudo vim /etc/postfix/main.cf

And add these lines, check if they are not already present before you add them to your file.

mydomain_fallback = localhost
mail_owner = postfix
setgid_group = postdrop
relayhost=smtp.gmail.com:587
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom

Start the Service

sudo postfix start

Configure your Client to Use localhost as SMTP Server

Point your email client to point localhost at port 25, that is it.