24 Mar 2005

configuring postfix for regular workstations

i've only really ever configured postfix for mail servers such as the one that used to serve liquidx.net and tse.id.au. so none of my configuration files for those servers would be suitable for my only primary gentoo workstation where i work.

our department doesn't allow workstations on the network to connect other SMTP servers directly (eg, port 25) to "protect" us from spam bots for those lucky souls who use windows. however, i still want to be able to send email out to my real-world internet email address rather than relying on my local mail on the workstation which i never read. i also don't need to receive any email from the outside world.

i use postfix because it is easier to understand than any of the other mail transport agents (known as MTAs) such as sendmail, qmail and exim. i think our department uses exim (since it is a cambridge piece of software), and it is very good, especially allowing users to define filters in their .forward file. none of the other MTAs i know support this out of the box.

back to postfix, there are only really four lines that you have to edit to get everything to work. gentoo installs postfix configurations in /etc/postfix, so we just have to edit /etc/postfix/main.cf:

myhostname = mymachine.somesubnet.biggersubnet.cam.ac.uk

mydomain = cam.ac.uk
myorigin = $mydomain
relayhost = <my university smtp server>

relayhost is the smtp server of that i can use to send mail out, it is one of the few hosts that the department allows us to connect to it's port 25 (btw, there is an increasing number of sysadmins opening port 2525 on their mail servers to get around these restrictions.) so we set that as our relay hosts. one other restriction is that the relay host verifies the user is from a valid domain (eg. if i send an email out from alastair@cam.ac.uk, it will try to check whether there really is a user alastair at the mail server cam.ac.uk), so we have to force all email to claim it originates from cam.ac.uk -- which is the myorigin line. the other lines are self explanatory.

one final note, i was getting some weird output in my mail logs when i started postfix, turns out that i had my old exim .forward file in my home directory with my filters and it was just basically trying to forward my mail to every one of the lines in my filter file, not smart!

You can reply to me about this on Twitter: