Open Source

Address Book with Mutt on Ubuntu Debian GNU/Linux

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 []
#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="~/"
set envelope_from=yes

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

The script is as follows

# 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.


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s