Using Postfix on the CUDN

Computing Service staff develop and maintain Exim, which runs on Hermes and ppswitch. Mail Support are therefore able to offer expert help with it, and we recommend that if you need to run an MTA on a Unix machine on the Cambridge University Data Network, you should use Exim. We have a suggested configuration file which is designed to do the right thing according to the rules for the use of email within the University, and we are happy to provide advice on how to adjust this configuration for your particular case.

However, many Linux and Unix distributions now come with Postfix as the standard MTA. We have limited experience with it though we try to offer advice when we can. If you do not want to install Exim, this document describes how to configure Postfix so that it will emit correctly-addressed email that will be accepted by ppswitch.


How to do it

The first thing to do is to configure Postfix to send all email via ppsw.cam.ac.uk. Edit the main.cf file, which is probably in the directory /etc/postfix/. You need to set the relayhost parameter as follows. Note that the square brackets are necessary to avoid MX lookups.

	relayhost = [ppsw.cam.ac.uk]

By default, Postfix uses the local machine name as its email domain, but computer names within cam.ac.uk are not a valid mail domains according to our rules.

Therefore we must configure Postfix to do some address rewriting, for which we can use its canonicalization feature. To turn it on, edit the main.cf file to set the canonical_maps parameter, for example:

	canonical_maps = hash:/etc/postfix/canonical

You then need to create the /etc/postfix/canonical table. Each line in the file is an email address pattern to match followed by a replacement address. You want to map all of the machine's local addresses to an externally valid email address, such as the address of the machine's admin or the role address of the responsible group, for example webmaster@botolph.cam.ac.uk. You probably also want to map some local user addresses to the corresponding @cam address.

The first requirement can be handled with a canonical table entry like

	@machine.botolph.cam.ac.uk	webmaster@botolph.cam.ac.uk

The second requirement wants table entries like this. (The pattern assumes @machine.botolph.cam.ac.uk on the end.)

	spqr1		spqr1@cam.ac.uk

After editing /etc/postfix/canonical you must run the command postmap /etc/postfix/canonical in order to build the working lookup table from the text file source. Do this each time you edit the file.

Finally you must run the command postfix reload to update the running configuration with the changes you have made.


Links to Postfix documentation

Note: we are using the canonical map feature instead of the "masquerade" feature because the latter would cause email to root@machine.botolph.cam.ac.uk to go to root@cam.ac.uk.

An alternative approach

The above technique will result in no local delivery of email (since local addresses are mapped to remote addresses). If you want local addresses to stay local, you can instead use the "generic map" for outgoing email. This is exactly the same as using the canonical map, except the setting to use in main.cf is:

	smtp_generic_maps = hash:/etc/postfix/generic

and the file containing the table has a different name. This requires version 2.2 of Postfix, so you should check that your copy is sufficiently new if you choose this route.


Tony Finch <fanf2@cam.ac.uk>

$Cambridge: hermes/doc/misc/postfix.html,v 1.6 2008/09/03 12:59:13 fanf2 Exp $