what is it

getmail3 is a small perl script for downloading pop3 mail from my ISP's mail server. I wanted to be able to read my mail on my shell account and then be able to download it later. Ideally I'd be using IMAP but that was disabled... Sounds like I should be using fetchmail running as a daemon. This is what I did initially (my ISP even has a nice little script to set up fetchmail for you). However, there are two things that mail server does that fetchmail doesn't like.

my response to this was to write my own perl script to take the place of fetchmail. It's not pretty but it works for my purposes. Someone else suggested that others might find value in this routine so here it is. This is the first version that I would consider letting out into the world. It requires no perl modules that don't come with perl itself and so it should be fairly portable and run without problems on most systems. It is however, rather feature poor. The configuration is a handful of variables at the program and doesn't have much configurability built in.

how to use

Download here.

modify the settings near the top of the file.

file, server and user can be overridden on the command line

run it: perl [file [server [user]]]

getmail3 will then ask you for your password and then go into the background and check your mailbox every 60 seconds or so

use your favourite mail reader to read your mail

how to stop it

umm, this isn't exactly implemented in any way. I've always just used ps and kill

what it does explicitly

while I'm annoyed at my ISP, out of principle I don't want to abuse the mail server too much so I've done as much as I can to minimize the work the mail server does while still being able to retrieve messages that are inserted into the middle of the list on the server. First it does a stat to see if the number of messages on the server is more than the number of messages that it has downloaded. If so it calls list to get a list of the message sizes. It compares the message sizes to the messages it has downloaded already (as reported by previous list calls) and if the message is potentially new (ie the number of messages of this size that have been downloaded is not equal to the number of messages on the server of this size) it gets the message header. It determines if the message is new by comparing the header to the headers of the previously downloaded messages (ignoring header lines defined in @ignoreLines) and downloads the message if appropriate.

what it doesn't do

first and formost getmail3 is extremely limited in scope of what it does. It also does not support any kind of encryption/mangling of the password so I wouldn't use it over any public network. I use it to get from my shell account to my mail server which are on the same network and the sysadmins of this network have access to this password anyway. It does not remove the final "." from the end of the message or unescape lines starting with "."

If you have any comments or questions about this script, I can be reached at

thanks, jim