E-mail with Alpine and fdm


I set about changing the way I log into my email account at work today. I like to keep my email clients separate for the different jobs I take on, and one thing that started to annoy me was that every time I wanted to access my email account at the radio station, I had to launch Thunderbird on my extremely slow desktop. If working from home, this meant that I had to use VNC in order to browse my inbox. Being a console junkie who does most of his work via SSH, I decided to pursue a text-mode solution.

Pine is the email client with which I gained the most familiarity during my initial forays into the *NIX world via Super Dimensional Fortress. It later became Alpine for licensing reasons, but it functions almost identically. It is easy for beginners and still has most of what’s needed for advanced users. I’ve used Mutt, but I didn’t grow up with it, so it’s more foreign to me. There’s a difference between what Mutt expects and what Alpine expects in the way they handle mailbox storage. Alpine uses the traditional mbox format, whereas Mutt uses the newer IMAP-oriented Maildir format. This can get messy during configuration of the program that fetches mail, so I had a hard time deciding between fetchmail, which has been accused of security holes, and getmail, which seems to be the newer more flexible cousin. However, I decided to go with what seems like a more streamlined approach and utilize a program called fdm, which I learned about through the Arch Linux Wiki. I may later change my mind and use getmail, but this works.

One problem I had at first was getting the program to log onto the server. Turns out my server doesn’t like APOP commands, so I added the no-apop directive to the ~/.fdm.conf file and it logged in properly:

# Catch-all action (mbox):
action "inbox" mbox "%h/mail/INBOX"
# Account info
account "me" pop3 server "mail***.opentransfer.com" port 110
    user "me@*******.com" pass "*********" no-apop
# Match all mail and deliver using the 'inbox' action.
match all action "inbox"

To make it check automatically, run crontab -e and add the following line:
*/2 * * * * fdm -q fetch

At this point, all that was left was to point Alpine to the new mailbox data file. This is done either from within Alpine using Setup Config inbox-path or editing the .pinerc. It should be set to ~/mail/INBOX. To make sending work correctly, it’s important to fill in the user-domain and smtp-server fields.

Now here’s the cool part: making it obvious that there’s mail whether or not I’m using Alpine. I modded my .bashrc file so that my prompt displays the number of unread messages (if any) in blinking text color. I’m a big fan of writing functions into my .bashrc, so here it is:

	NUMUNRE=`grep -c '^Status: [^R][^R]\?' ~/mail/INBOX`
	NUMSTAT=`grep -c '^Status: ' ~/mail/INBOX `
	NUMFROM=`grep -c '^From ' ~/mail/INBOX`
	if [ "$NUMINBOX" != "0" ] ; then
		echo -ne "\e[5m$NUMINBOX\e[25m "
PS1='\[\e[32m\]$? \[$(numinbox)\]\[\e[4m\]\u@\h \W\[\e[1m\]\$\[\e[0m\] '

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: