Postfix on OSX: Revisited
A few years back, I had written a post on enabling the Postfix MTA as a relay server on OSX, which was quite well received. The article was originally written for OS X Lion, though it remained valid for OSX Mountain Lion, and more recently on
OSX Mavericks as well.
However, things have changed on the OS since the last two versions, which warrants a revisit of the instructions, and a refresh of some of the steps. While the old set of instructions still work, there are changes needed that will keep the configuration future-proof.
The key changes since the article was posted (in February 2012) are:
- The launchd configuration has changed somewhat, and a few elements of the launchctl plist file are now deprecated. The old configuration in the
org.postfix.master.plistneeds to be refreshed
- The old configuration depended on local mail-drop in the Postfix queues for the MTA daemon to be started. While this is quite correct (this is Unix, after all), there is another common scenario where the daemon is launched when a client connects to the SMTP ports (default port 25) on the
The Updated launchd Configuration
We would like to retain running the daemon on a mail-drop in the queue, but also enable running the MTA when a connection is made to the SMTP port (default 25). The updated
org.postfix.master.plist configuration file listed below does this for us.
In addition, the redundant and deprecated plist tags have also been removed.
You can replace the existing copy with this version as a drop-in replacement at
/System/Library/LaunchDaemons/ by using the following shell commands in Terminal.app (assuming you have downloaded the new version at
$ cd /System/Library/LaunchDaemons/ $ sudo cp org.postfix.master.plist org.postfix.master.plist.old $ sudo cp ~/Desktop/org.postfix.master.plist .
The actual configuration file:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.postfix.master</string> <key>ProgramArguments</key> <array> <string>/usr/libexec/postfix/master</string> <string>-e</string> <string>60</string> </array> <key>Sockets</key> <dict> <key>Listeners</key> <dict> <key>SockServiceName</key> <string>smtp</string> <key>SockType</key> <string>stream</string> </dict> </dict> <key>QueueDirectories</key> <array> <string>/var/spool/postfix/maildrop</string> </array> <key>AbandonProcessGroup</key> <true/> </dict> </plist>
Once the file has been copied into the correct location (perhaps by using
sudo), we need to reload the configuration into
$ cd /System/Library/LaunchDaemons/ $ sudo launchctl unload org.postfix.master.plist $ sudo launchctl load -w org.postfix.master.plist
This should be sufficient to reload the new configuration.
Testing out the configuration
We can test the changes via the shell itself by trying to connect via telnet to the smtp port and trying out a few basic SMTP commands (
HELO for checking a response, and
QUIT to logout of the SMTP session):
$ cd ~ # Lets get back to $HOME directory $ mail <your_id> # Send yourself an email to check mail-drop $ telnet localhost smtp # Now lets telnet into the server Trying ::1... Connected to localhost. Escape character is '^]'. 220 localhost.local ESMTP Postfix HELO 501 Syntax: HELO hostname QUIT 221 2.0.0 Bye Connection closed by foreign host.
In the sample SMTP session above, the third line (starting with “220” response) indicates that the Postfix MTA is running, and is ready for accepting mail drops via the SMTP port (as opposed to the mail-drop via the