Let's say you want to have a functioning email system where you can use
exim (or
postfix or
sendmail...) to deliver your emails and
fetchmail or something equivalent to retrieve it, with
procmail to sort your mail into neat little mailboxes and
mutt as your MUA. It shouldn't be too hard, right? After all, lots of folks have a setup like this. Now let's say you want to subscribe to a high-volume mailing list, like
LKML. You'll need an email service that is:
- Reliable
- Has a lot of storage space
- Has a domain that's free of spammers and other kinds of abusive people
- Supports POP3 and SMTP
I could use my CS account, but then it's neither reliable nor has a lot of storage space. I could use my ISP's email, but it fails the first three criteria. Therefore, using GMail is my only remaining option.
Setting up fetchmail to get emails from your GMail inbox isn't hard, and there are numerous guides on the internet on how this can be done. I found
this guide to work for me. The following is a cliff notes step by step procedure of what to do (I put my certs into
~/.certs
instead of the system-wide
/etc/ssl/certs
):
$ mkdir ~/.certs
$ cd ~/.certs
$ wget -O Equifax_Secure_Certificate_Authority.pem https://www.geotrust.com/resources/root_certificates/certificates/Equifax_Secure_Certificate_Authority.cer
$ chmod 644 Equifax_Secure_Certificate_Authority.pem
$ openssl x509 -in Equifax_Secure_Certificate_Authority.pem -fingerprint -subject -issuer -serial -hash -noout
$ c_rehash .
Now, assuming that you've enabled POP3 in your GMail account preferences already, you can use the following
.fetchmailrc
example to grab your email:
# Set some defaults
defaults protocol pop3,
timeout 300,
nokeep,
mda "procmail -f-"
# Get mail from Gmail
poll pop.gmail.com
user 'gmailusername' there with password 'topsekrit' is localusername here
ssl sslcertck sslcertpath /home/localusername/.certs
Change
gmailusername
, the password, the certs directory (
/home/localusername/.certs
) and
localusername
to values that make sense for your system. The
nokeep
option removes email from the server, so you might want to change that to
keep
if you like GMail to retain the messages (I don't know if that option works correctly with GMail, though).
Next you'll need a
.procmailrc
. Mine is relatively unsophisticated (everything goes inside the inbox):
PATH=/bin:/usr/bin:/usr/bin
MAILDIR=$HOME/Mail
LOGFILE=$MAILDIR/procmaillog
# All mail goes to Inbox
:0:
Inbox
For setting up exim4 for mail delivery via gmail,
this guide at the Debian wiki gives a solution that works pretty well.
Finally, you might want to automatically retrieve email via a cron job (this does it every 15 minutes):
$ (crontab -l 2> /dev/null | echo '0,15,30,45 * * * * fetchmail') | crontab -