How to use Fetchmail
As written by a Linux noob
If you have a CompSoc Toast account, then you have a matching e-mail account on the server. It can give you much more features and freedom than the seperate exchange/durham.ac.uk e-mail account such as downloading mail using your favourite program.
Please be clear that means two seperate e-mail accounts, on this page we will refer to them in the following way:
- exchange (account) - managed by ITS, your username is something like d8abcd and e-mail like firstname.lastname@example.org/dur.ac.uk
- (compsoc) toast (account) - managed by the CompSoc admins. Username is your compsoc account name (e.g. fred) and e-mail address e.g. email@example.com
To access/read/view/send your CompSoc toast mail you...
- SSH onto toast and use one of the programs
- enter mail(really basic, good to test), press q to quit.
- pine and mutt are other programs installed.
- Download your mail using your favourite mail client (Outlook, Thunderbird, Evolution, etc.) via IMAP (port 993) or POP3 (port 995):
- Server: compsoc.dur.ac.uk
- Username/password: Your Compsoc/Toast login details (as in firstname.lastname@example.org)
- Security: SSL, don't use secure authentication
- Note that the certificate will be from pitta, which is toast (before it's cooked?).
Getting emails to Toast
- SSH into your toast account, and create and edit a file .fetchmailrc (note the filename starts with a dot, that means it's a hidden/special file).
- One way is to enter vi .fetchmailrc then press i to be in edit mode of the vi editor, now type the following.
poll eximap.dur.ac.uk proto IMAP user "[ITS Username]" password "[password]"
- Note that this changed from eximap.mds.ad.dur.ac.uk in January 2011 due to a slight re-ordering.
- To save in vi press Esc, :, w, Enter, then enter :q to quit the editor.
Moving the emailsTry running "fetchmail", it should now check your emails and give a response like:
"fetchmail: No mail for [ITS Username] at eximap.dur.ac.uk"This is the end of the first step, well done.
Automating fetchmailSo our emails are getting to Toast when we run a script, but wouldn't it be nice if we didn't have to run a command every time we wanted emails.
- enter crontab -e
- like vi editor press i to edit
- add a new line (the # line is a comment) as the following:
*/20 * * * * fetchmail -s
- press Esc then enter :w and :q to save/quit.
- It should say crontab: installing new crontab if you did it right.
You just added a cron job to run fetchmail every 20 minutes. The -s parameter puts fetchmail into silent mode - you will get and email telling you it has run every time without.
Forwarding the emails
So what if you want to use Gmail (or your other favourite service that can't get emails from IMAP)?Much like creating the .fetchmailrc file, we need a .forward file. So as before:
- vi .forward and enter:
- as before, save the file and quit vi
If you want to keep your mail on Toast as well, you might think to add your @compsoc.dur.ac.uk adress in too. But don't - this will create a mail loop and bad things will happen. Instead, you need to prefix it with a "\" giving:
email@example.com \firstname.lastname@example.orgThis will forward a copy whilst keeping a copy for you.
Last edit: Wed 11th May, 12:55 a.m.