[Debian] ISP email backup with fetchmail using POP3
Saturday, September 20th, 2008This week a windows machine in my home network crashed. It was using POP to retrieve emails from our ISP. IMAP was no option due to a 50MB Inbox restriction on their side. Luckily I was able to recover the .pst files for outlook so there was not really a big problem there. However I started thinking of a solution to get the email from the ISP onto a server in the home network. Then this server would provide a IMAP service for getting the email. In this way, the email could also be shared between multiple machines and since I’m synchronizing all servers in the home-network regularly I would always have a backup.
So I needed:
- An IMAP server.
- An email fetcher to get the email from the ISP
I already had the IMAP server configured. Dovecot if you are wondering. Together with Exim 4 as my MTA. So, I needed a mechanism to fetch my email. So, I started googling. In the end using the wrong keywords, because all I ended up with were IMAP proxies, which I don’t need. Finally, I tried posting on a forum and somebody there suggested fetchmail. How obvious!!
Anyway, I looked up the fetchmail documentation a bit and it seems to do everything I need.
So, I installed fetchmail:
apt-get install fetchmailAfter reading the debian documentation I ended up creating a fetchmailrc file:
touch /etc/fetchmailrc
There are many options in this file but I’ll show you what I’ve put in there:
set syslog # We want logging to go to syslog set no bouncemail # We trust the ISP's spam filter poll pop.isp.tld with proto POP3 # A new POP3 poller user USERNAME there with password PASSWORD is UNIX_ACCOUNT here antispam -1 # We trust the ISP's spam filter
Where USERNAME is the user name of the user to authenticate with to your ISP. PASSWORD is the password that belongs to that user name. UNIX_ACCOUNT specifies the local account to deliver the emails to. For examle I put my name there since that is the account I use on that machine.
If you want to leave a copy of the email on the ISP’s server, you should use the ‘keep’ parameter on the poller you would like to use it for.
edit /etc/default/fetchmail so that ‘START_DAEMON’ says ‘yes’:
START_DAEMON=yes
Start the fetchmail service
/etc/init.d/fetchmail start
Use:
tail -f /var/log/syslog
To see how your mail fetcher is doing.
You might also wonder about the plain-text passwords in the /etc/fetchmailrc file:
-rw------- 1 fetchmail root 287 2008-09-19 13:47 fetchmailrc
As you can see you’ll need root access to see the file.
Fetchmail is a very complete application, with lots of options. I really recommend taking a look at this application and see what it can do for you.
