Address Book with Mutt on Ubuntu

March 28, 2008

I have been using Mutt MUA for a little while now and it is apparent that I need some kind of address book. The solution outlined here saves address automatically when you send email.

This solution is better for me than saving received addresses. Think spam etc.

The addressbook used os lbdb, little brother database.

My lbdb is installed and setup with the following in ~/.lbdbrc


# my lbdb config file

# methods to search [www.spinnaker.de/lbdb/]
METHODS=”m_inmail”
#m_muttalias m_palm m_gpg m_ldap

To save addresses when sending, I replace the mutt sendmail option which was using esmtp to now point to a custom script.
The script uses the tee command to send a copy of the mail to lbdb for address harvesting, and another copy to esmtp as before. I also added an option to tell mutt to use lbdb for address queries.

The changed and new options in ~/.muttrc are


set sendmail=”~/esmtp-lbdb.sh”
set envelope_from=yes

# use lbdb for email address querying
set query_command=”/usr/bin/lbdbq ‘%s’”

The script esmtp-lbdb.sh is as follows


#!/bin/bash
#
# Script must run with Bash so keep above
# send mail with esmtp but send a copy to lbdb-fecthaddr to harvest address
#
echo -e \\n \\n MARK \\n \\n >> /tmp/test.log
echo “$@” >> /tmp/test.log

# harvest mail (stdin) and major to address
# tee the stdin,
# tee splits input into two copies, one to named file, one to stdout
# instead of named file, we redirect to command, and the other copy to stdout is piped to a second command
#
# the first command harvests email addresses from the input email
# the second command sends the input e-mail, and takes the parameters via “$@” which are the from and to/cc/etc addresses
tee >(lbdb-fetchaddr -a) | /usr/bin/esmtp -v -X /tmp/esmtp.log “$@”

When sending an email in mutt, I can press CTRL-T to get the list of addresses from lbdb and choose one for inclusion.


Setting up Email with Mutt on Ubuntu

March 28, 2008

I have been using the Mutt email client for a short while now. By no means an expert, but have found a few little gems.

Firstly, I am using external POP and SMTP for sending and collecting email, with no local email server.

I use the following basic mutt settings in ~/.muttrc


set mbox_type=Maildir
set folder=”~/email/mailbox”
set mask=”!^\\.[^.]”
set mbox=”~/email/mailbox/kept
set record=”+.Sent”
set postponed=”+.Drafts”
set spoolfile=”~/email/mailbox/in-default
set realname=”me”
set from=”me@domain.tld”
set use_from=yes

As you can see, the mailbox are all in a folder in my home directory, no use of spool etc as I am not running an email server.

For sending email I use esmtp with this option in .muttrc


set sendmail=”/usr/bin/esmtp -v -X /tmp/esmtp.log”
set envelope_from=yes

For receiving email, I use getmail via cron every 15 mins.
The cron is :


crontab -l
# m h dom mon dow command
*/15 * * * * getmail –getmaildir /home/me/email/getmail/ –rcfile getmail.me.rc

The retriever in the getmail config is SimplePOP3SSLRetriever, and the destination is to procmail, which then does filtering based on rules and filters i set up and drops the email into the various maildir folders in ~/email/mailbox/