
My PostFix Setup

(Last update: 2005-07-30
If you used sendmail in Jaguar, you've noticed that Panther replaced it with postfix. Actually, sendmail appears to be still present, but in fact now it's just a stub that redirects everything to postfix for backwards compatibility (see man sendmail
).
I was using sendmail in Jaguar mostly to get emailed the output of my cron tasks, and here's how I set up postfix to achieve the same result in Panther and Tiger. This may not be the best way, but it's been working fine here for years, now. OTOH, incoming emails are blocked by the firewall, on my machines, so if this is not your case make sure to check the postfix man page (man postfix
), the aliases man page (man 5 aliases
) and the contents of /etc/postfix/main.cf
(AFAIK, postfix's incoming access is closed by default).
I. Setting up postfix's config
The only thing I had to add in there is my domain name:
- First, backup the original file:
sudo ditto /etc/postfix/main.cf /etc/postfix/main.cf.default - Then open
/etc/postfix/main.cf
(still as root):
% sudo pico /etc/postfix/main.cf - Locate the
INTERNET HOST AND DOMAIN NAMES
section. It ends with:
#myhostname = host.domain.tld
#myhostname = virtual.domain.tld - Create a new line below, and type (using your own domain name, of course):
myhostname = myDomain.net - Save and close /etc/postfix/main.cf
II. Setting up the aliases file
- Go to /etc
% cd /etc - Notice that etc contains a symlink named "aliases" that points to "
/postfix/aliases
. Rather than editing that file, we'll create our own. First we rename that alias:
% sudo mv aliases aliasesReadme - Then we'll copy the contents of the file it points to:
% cat postfix/aliases - This file starts with a sample of the config file, followed with the man page. Since we only want the config part, copy everything above the line that goes:
# ALIASES(5) ALIASES(5) - Create a new aliases file in /etc:
% sudo pico aliases - Paste the config sample copied from postfix/aliases.
- Locate the line that reads:
# Person who should get root's mail. Don't receive mail as root! - On the line below ( "#root: you"), replace "you" with your short username, and remove the pound ('#'). This line instructs postfix to forward to you the emails sent to root.
- Save and close the file.
- Now run the following to rebuild aliases.db:
% sudo newaliases
III. Sending out
So far the emails aren't sent out and are visible only in Terminal (see man mail
). But it's very easy to get them sent to your public email address, so they'll show up in your emailer wherever you are:
- Open or create ~/.forward:
% pico ~/.forward - Just enter your email address (with no quotes). If you want the messages redirected to several addresses, put them each on a different line. And if you want to get the emails in Terminal too, add your short username.
- Save and close the file.
IV. Launching the mail server at startup
It's necessary to make sure that the mailserver will be launched at startup, but the method isn't the same in Panther and Tiger:
Panther:
- Run:
% sudo pico /etc/hostconfig - Locate
MAILSERVER
and make sure it's set to-YES-
. - Save and close the file.
Tiger:
- Run:
% sudo pico /System/Library/launchDaemons/org.postfix.master.plist - Locate
<string>org.postfix.master</string>
, create a new line bellow, and type the following lines:
<key>OnDemand</key>
</false>
So at this point, the plist will begin 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">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.postfix.master</string>
<key>OnDemand</key>
<false/>
<key>Program</key>
<string>/usr/libexec/postfix/master</string> - Save and close the file.
V. Launching or reloading postfix
Finally, in Panther postfix has to be launched--or to be told to reload its config file if it's already running (this isn't necessary in Tiger):
- Run:
% sudo postfix start - If the result is
postfix/postfix-script: fatal: the Postfix mail system is already running
, then run:
% sudo postfix reload - This will reload postfix with the edited config file.
VI. Root's tasks reports
(That part was updated on 21/02/2005, thanks to John Baltutis' comments, to match system changes introduced later in Panther.)
With this setup, you'll get by email the result of your own cron tasks and the emails sent to root. However, by default the result of the root's cron maintenance task (the daily, weekly and monthly cleanup tasks) is written to the /var/log directory instead of being emailed. To get these by email too, it's necessary to override the task output variables resident in the periodic configuration file located at /private/etc/defaults/periodic.conf (periodic is the "engine" of cron). But rather than editing that file, we'll create our own periodic conf file :
- Open or create /etc/periodic.conf.local
% sudo pico /etc/periodic.conf.local - Add the following lines:
#!/bin/sh
#
daily_output="root /var/log/daily.out" #sends it to both
weekly_output="root /var/log/weekly.out" #sends it to both
monthly_output="root /var/log/monthly.out" #sends it to both - Save and close the file.
Comments
Previous Comments
Below are existing comments.
There are no comments yet. Be the first to post one!
Please Log in if you wish to comment.