Using fetchmail with Exchange at the Wellcome Trust Sanger Institute

This a post migrated from my old blog at Linuxjunk:

If you ever go work at Sanger and you’re a UNIX/mutt/pine user get them to put you on the UNIX mail server not the Exchange server, once they’ve set you up on one they’ll never change it… If you’re on exchange it’ll be a world of pain and mutt will take 30mins to open your mailbox over IMAP (fact).

However, if you do find yourself on an exchange server you can use fetchmail to grab your mail and filter it in to a mailbox using procmail. Here’s the fetchmail config I use at Sanger, put this in .fetchmailrc:

set postmaster YOURUSERNAME

poll exchsrv2 with proto imap user "YOURUSERNAME" there with password "YOURPASSWORD" is "YOURUSERNAME" here keep options stripcr
mda "procmail -f %F"

This is my .procmailrc it also forwards to an external address as well as delivering to a local mailbox:

set postmaster YOURUSERNAME
SHELL=/bin/sh
DEFAULT=/var/mail/YOURUSERNAME
LOGFILE=/Users/YOURUSERNAME/procmail.log

MAILDIR=$HOME/mail
DEFAULT=$MAILDIR/inbox

PMDIR=$HOME/Procmail

INCLUDERC=$PMDIR/rc.subscriptions

:0c                     # That's colon, zero, lowercase cee
! [email protected]     # That's exclamation mark, address to forward to

You’ll need to configure postfix or whatever (I’m on a Mac) to relay mail via the local SMTP server as well. For postfix/max stick this in main.cf:

relayhost = mail.internal.sanger.ac.uk