I contributed an article for using Postfix to the Entourage FAQ a while ago. Tiger introduced some drastic modifications to the way startup items are dealt with ad the article needed to be updated. Here is a second draft at the revised article incorporating Tiger instructions. The article has been recently improved following comments and help from Jean-Pierre Nouet on fr.comp.os.mac-os.x . Comments are MORE than welcome…
Using Postfix as an alternative to Exchange SMTP servers to send mail
Some of us have had some issues with their Exchange SMTP servers (refusing to send e-mail for alternate addresses or simply refusing to send any mail at all). MacOS X 10.3 and 10.4 now has Postfix preinstalled which can turn your Mac into an SMTP server.
If the port 25 is open on your network (which is often the case), you can turn your own Mac into your SMTP server very easily in MacOS X 10.3 (it is far more complex in 10.2.8 which uses Sendmail by default instead of Postfix – though you can install Postfix if you really really want to but this won’t be covered here).
You have two options to enable Postfix. You can use a shareware like “Postfix enabler” for earlier versions of the System and “MailServe” (same author) for Tiger, or you can do it yourself (not that hard – and free).
The sharewares I mention are very easy to use, offer a very nice GUI and allow you to configure a lot of parameters without ever having to dig through the Postfix documentation. They might well be worth spending a few dollars!!
Nevertheless, if you decide to do it manually, you can use your favorite MacOS X text editor or do it directly in the Terminal through pico, vi, vimm…… I’d suggest that you backup the files before you decide to do anything nasty:
sudo cp /etc/hostconfig /etc/hostconfig.old
sudo cp /etc/postfix/master.cf /etc/postfix/master.cf.old
I recommend using TextWrangler by BareBones Software (free) which offers a very nice user interface and properly deals with invisible files and Permissions (which is critical here since all the following modifications have to be done in Administrator privileges – the application will ask you for your administrator password every time it is required).
For MacOS X 10.3.x (Panther)
Open the hidden file /etc/hostconfig with TextWrangler (Menu “File:Open Hidden…”) and replace MAILSERVER=-AUTOMATIC– with MAILSERVER=-YES–
Open the hidden file /etc/postfix/master.cf at line 77, you need to de-comment “smtp”. Replace: # smtp with smtp
in the Terminal, then enter:
sudo postfix start
Authenticate AND THAT’S IT !!!!! You’re done The address of your own personal SMTP is now “localhost” (without the quotes of course).
For MacOS X 10.4 (Tiger)
Tiger has a whole different way to deal with processes that launch at startup. The hostconfig file and the
rc command is now obsolete since the system now uses a new scheme called
launchd to manage such processes (you can type
man launchd in the Terminal to learn more about it). In order to reduce startup time and useless use of resources,
launchd makes sure it only runs some specific background processes only when needed (and it shows!!! Look at how fast the startup is in Tiger…).
In Tiger, Postfix has all the options it needs to be active by default, but it will only run in specific circumstances defined for
launchd in /System/Library/LaunchDaemons/org.postfix.master.plist.
< ?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
You can manually launch Postfix using the command
sudo postfix start in the Terminal, but the process won’t be running next time you reboot.
To have the process run every time you reboot, you’ll need to tell
launchd that you want postfix to run all the time (and not only when triggered by the System).
The org.postfix.master.plist file is a well-structured XML document and you can add a “key” in the file to make sure
launchd knows the process has to run continuously. Apple now has a technote about startup items in Tiger and how these .plists are structured.
Two parameters need to be modified in this file. The process needs to be launched at boot and run continuously (OnDemand set to False) and to avoid conflict, the parameters that told
postfix wehre to look for jobs to process in the previous scheme have to be deleted (since they’re redundant when
postfix is running all the time).
First make a backup copy of the original file. In the Terminal, run:
sudo cp /System/Library/LaunchDaemons/org.postfix.master.plist /System/Library/LaunchDaemons/org.postfix.master.plist.bckp then open /System/Library/LaunchDaemons/org.postfix.master.plist in TextWrangler and replace its content with:
< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
As you can see in this file, we added:
A copy of the org.postfix.master.plist is available here (Control-click the link to download it directly – if you simply click th link, your browser might try to render it, making most code invisible) if you just want to copy and paste in the original file (avoid replacing the original to make sure you don’t end-up with corrupted permission settings) to make sure you don’t make any mistake setting it up.
Save the File and reboot. Postfix should now be running all the time, allowing you to use 127.0.0.1 or “localhost” to send e-mails from your Mail client (e.g.: Entourage).
Extra configuration can be perform editing the /etc/postfix/main.cf This file is fairly straightforward. The default settings are rather safe: They even disable any relaying from other machines….. You shouldn’t turn your Mac into a relay for spammers.
After a modification in the configuration file, simply enter in the Terminal:
sudo postfix restart
This saved my life (well my e-mails) here since our Exchange server won’t send e-mails unless the From address corresponds to its user list, preventing me to send anything from my numerous alternate addresses…
PS: I should add “use at your own risk” I can just tell you than I’ve been using Postfix for a while now and it has been smoother than ever. No problem on my Mac whatsoever.
Contributed by Corentin Cras-Méneur, Mac:MVP