My Postfix Configuration

The following documents the steps I took to enable Postfix on my Mac, running Mac OS X 10.3.x and 10.4.x. Your mileage may vary.

To enable outgoing email:

  1. Install the excellent Postfix Enabler.
  2. For my ISP (Verizon), the only required field in Postfix Enabler you need to fill out is the Masquerade As field (I entered verizon.net).
  3. Press the Enable Postfix button, and you should be all set!
  4. You should be able to send mail to regular email addresses, like foo@bar.com. To send & receive email to local user accounts, see the next section.

To enable local email:

  1. The above Postfix Enabler steps basically adds one line to /etc/postfix/main.cf:
         myorigin=verizon.net
  2. Unfortunately, according to the Postfix main.cf file format page, myorigin is the:
    ...domain name that locally-posted mail appears to come from, and that locally posted mail is delivered to.
  3. In practical terms, that means mail sent from a Mac OS X user account (called, say, foobar), will actually appear to come from foobar@verizon.net.
  4. Additionally, if you were to try to send mail from the command line to foobar, Postfix would try to deliver it to foobar@verizon.net. This might happen to work out very well, if you happen to have the same name for your Mac OS X user account name and your ISP's email account (I don't).
  5. The simplest solution is to send all email to foobar@localhost. Postfix will still append $myorigin (verizon.net) to the end of the email address, making foobar@localhost.verizon.net, which isn't a real adress. However, Postfix manages to correctly deliver it to the local foobar email account.
  6. The above solution requires you to remember to add @localhost to all of your local emails, and to explicitly edit any cron jobs you might have so that they send email to the correct address! A better solution is to tweak Postfix's configuration a little more!
  7. Inside Postfix Enabler, go to the Mail Server tab and add the following line to the Custom Postfix Settings section:
         virtual_alias_maps = hash:/etc/postfix/virtual
    and then press the Restart Postfix button.
  8. Using root or sudo, edit /etc/postfix/virtual to include lines like:
         foobar foobar@localhost
  9. Using root or sudo, type to following commands to reconfigure and restart Postfix:
         postmap /etc/postfix/virtual
         postfix reload
    (Note that typing postfix reload is the same as pressing the Restart Postfix button in Postfix Enabler.)

To enable email for the root account:

  1. It seems like no matter what I tried, receiving email in the root account seems to be disabled by Mac OS X.
  2. What you're supposed to do is put your username as an alias for root inside /etc/postfix/aliases. I can't remember if Postfix Enabler does this for you or not. If you have to do it (or want to make changes), edit /etc/postfix/aliases and then type:
         newaliases
  3. If you really, really want to receive email directly inside the root account, you should first ask yourself why you even have the root account enabled. It's considered a major security risk - you should do all of your administrative stuff using sudo. Well, if you're still determined to do it, edit /etc/postfix/aliases to send root's email to the account nobody. Then add the following lines to /etc/postfix/virtual:
         nobody nobody@localhost
         root root@localhost
    Then type:
         newaliases
         postmap /etc/postfix/virtual
         postfix reload
         echo placeholder | mail -s "Don't delete this message!" nobody
         cd /var/mail
         ln -s nobody root
  4. All email sent to root will be redirected to nobody (because of /etc/postfix/aliases). When root checks for new email, it actually sees nobody's email file (because of the symbolic link in /var/mail), and treats it as root's.
  5. One problem with the link is that Mac OS X will actually delete the link (/var/mail/root) if the target (/var/mail/nobody) is ever deleted. So, never delete that first email we sent above, or you will lose your link!