nix, shell, perl, php, mysql and mac os x tips and tricks

Friday, January 13, 2012

Fix for Postfix mail issue after upgrading from OS X 10.6 to 10.7

Postfix stops working. It throws errors like:
Jan 13 12:18:52 huggybunny postfix/master[2254]: warning: process /usr/libexec/postfix/smtp pid 2299 exit status 1
Jan 13 12:18:52 huggybunny postfix/master[2254]: warning: /usr/libexec/postfix/smtp: bad command startup -- throttling

I had it set up to replay through GMail. Looks like the /etc/postfix/sasl_password file was deleted during the upgrade. All I had to do was create it again per these instructions, reload postfix and it was good to go.

UPDATE: that link appears to have disappeared. Here's what you do:

Gmail Email Relay using Postfix on Mac OS X 10.5 Leopard


I use Postfix to relay system messages (e.g. a botched cronjob) over SSL to my Gmail account. These messages are otherwise “lost” because the email is being sent to a dormant mail transfer agent on my Mac. There’s way more that you can do with Postfix, but I’ll just cover the setup I did for my needs.

1. Create the Simple Authentication and Security Layer (SASL) password file.

sudo vi /etc/postfix/sasl_passwd

Enter and save the following

smtp.gmail.com:587 your.name@gmail.com:your.password
2. Create a Postfix lookup table for SASL.

sudo postmap /etc/postfix/sasl_passwd

3. Configure Postfix with

sudo vi /etc/postfix/main.cf

By default, everything is commented out. You can just append this to the end of file and save:

# Minimum Postfix-specific configurations.
mydomain_fallback = localhost
mail_owner = _postfix
setgid_group = _postdrop
relayhost=smtp.gmail.com:587
# Enable SASL authentication in the Postfix SMTP client.
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options=

# Enable Transport Layer Security (TLS), i.e. SSL.
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom

5. Start postfix with

sudo postfix start

If you get an error, address the parameter in main.cf that is in the error and use

sudo postfix reload

to refesh Postfix. If everything looks good, then send an email

date | mail -s test your.name@gmail.com

If you don’t get an email fairly quickly, enter

mailq

and you should see the email there along with a description of any problems. If the mail is not in the queue, you most likely got something wrong in main.cf so you’ll need to do some debugging. If your mail queue starts to fill up during this process, you can clear it with

sudo postsuper -d ALL

6. Once you have everything working, you can set Postfix to start on boot by adding a key to /System/Library/ LaunchDaemons/org.postfix.master.plist. If you have Property List Editor (or something similar), you can add the key RunAtLoad of type Boolean with a value that is checked.

Alternatively,

sudo vi /System/Library/LaunchDaemons/org.postfix.master.plist

and add the following just before the tag

RunAtLoad

1 comment: