Wednesday, 12 August 2009

Using Getmail to get your NHSnet emails

Getmail is a small python script to download automatically emails from a variety of servers. Unlike fetchmail it is stable, easily configured and does not do your head in. Unlike fetchmail it does not run as a daemon, but requires to be called regularly by the user. I use crontab for this purpose.


My getmailrc looks like this:



[Our Mail]

[retriever]
type = SimplePOP3SSLRetriever
server = pop.nhs.net
username = xxxxxxx@nhs.net
password = SECRET_PASSWORD

[destination]
type = Maildir
path = ~/Maildir/

[options]
verbose = 0
read_all = False
delete_after = 10
delievered_to = True
message_log = ~/.getmail/log


Important is the delete_after option - this will keep your emails for another 10 days on the NHS net webserver, allowing you to check your emails via webmail when outside of the practice.

I am using the pop retriever. There is the option of using an imap retriever, but I am not sure if this will really bring any benefit.


My crontab looks like this


0,10,20,30,40,50 * * * * getmail --rcfile /home/mail/.getmail/getmailrc

This means that my account is checked every 10 minutes.

If you have a full NHS net account, run getmail once directly from the commandline to download the bulk. Start your crontab only after you have downloaded everything the first time. Otherwise you will get a mess of dublicate emails and very slow downloads

No comments:

Post a Comment