13.3 Postfix

As of Mac OS X Panther, setting up a local mail server just got a lot easier. Apple has given up on the aging and clunky sendmail, and is instead using Postfix, which is easy to configure. (However, Postfix includes a sendmail-compatibility wrapper in /usr/sbin/sendmail .) The following sections describe how to configure Postfix in various scenarios.

After you make any changes to Postfix's configuration files, you should reload its configuration by running the command sudo postfix reload .


13.3.1 Configuring Postfix to Send Email

By default, Mac OS X runs a program called postfix-watch , which corresponds to the MAILSERVER=-AUTOMATIC- in /etc/hostconfig (a setting of -YES- starts the postfix server). The postfix-watch daemon monitors the outgoing mail queue, and runs Postfix on the queue as needed.

If you want to use Postfix on a standalone server, you must configure two settings in /etc/postfix/main.cf . The first is the hostname ( myhostname ). This should be a real hostname, something that can be found in a reverse DNS lookup against your IP address. The second is your origin ( myorigin ), which is the domain name from which email appears to originate. This can be the same as your hostname (this will probably be the case for small sites). However, if it is not, be sure to specify the correct hostname. For example, here are the settings for a computer named ip192-168-0-1.ri.ri.cox.net with all email originating from that machine appearing to come from username@cox.net :

 myhostname = ip192-168-0-1.ri.ri.cox.net myorigin = cox.net 

13.3.2 Configuring Postfix to Receive Email

To enable Postfix to act as a legitimate email destination (that is, mail for username@yourhost will go directly to your Macintosh), you must set MAILSERVER to -YES- in /etc/hostconfig and uncomment the following line in /etc/postfix/master.cf :

 #smtp      inet  n       -       n       -       -       smtpd 

After that change, it should now read:

 smtp      inet  n       -       n       -       -       smtpd 

To receive email at your host, you will need a Mail Exchange (MX) record pointing to your machine. The MX record is an entry in DNS that identifies the mail server for a particular domain. If your ISP provides you with a static IP address and supports the use of hostnames (this is a given if your Mac is co-located), contact them about setting up the appropriate MX record. If you have residential (or low-end business) broadband, it's very likely that your ISP does not support this, and what's more, they probably block access to port 25 within their network as a security precaution.

If your system can support the use of port 25, you must change the setting for inet_interfaces in /etc/postfix/main.cf . By default, it listens only on 127.0.0.1 (localhost), so you must add the IP address you want it to listen on. For example, we've set up a server behind a firewall, but configured the firewall to relay port 25 to the server (see Section 13.1.1, earlier in this chapter). The private network address of the server is 192.168.254.104, and because traffic on port 25 is going from the outside world to the private network, we must configure inet_interfaces to listen on the 192.168.254.104 interface as well as localhost:

 inet_interfaces = localhost 192.168.254.104 

After you make this change, stop and restart Postfix with postfix stop and postfix start (it may not be enough to use the command postfix reload ).

13.3.3 Configuring Postfix with a Relay Host

If you don't have a permanent domain name for your Mac OS X machine, we suggest configuring Postfix to use a relay host (most likely your ISP's SMTP server). To configure Postfix to use a relay, add an entry for relayhost in /etc/postfix/main.cf . For example, we use the following setting:

 relayhost = smtp-server.ora.com 

Along the same lines, you should configure Postfix to masquerade as the appropriate host using the myorigin setting in /etc/postfix/main.cf . In the case of the previous example, the origin is oreilly.com (as in bjepson@oreilly.com ):

 myorigin = oreilly.com 


Mac OS X Panther for Unix Geeks
Mac OS X Panther for Unix Geeks
ISBN: 0596006071
EAN: 2147483647
Year: 2003
Pages: 212

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net