Automatically add contacts to KAddressBook with KBBDB

258

Author: Mayank Sharma

Managing your address book and appending new addresses can get tiresome. If your email client is KMail, KBBDB can help with part of the job. This Perl-based filter sits idle waiting for messages to show up, then extracts any new sender’s email address into KAddressBook.

The utility is inspired by the Insidious Big Brother Database (BBDB), which is a contact management utility for Emacs. If you use [X]Emacs as an email client, BBDB can watch incoming messages, and whenever a new email address is spotted, it automatically adds it to the contact list, maintained in its own database.

Similarly, whenever KBBDB is called upon, it extracts addresses from the message, creates a little vCard file, and invokes KAddressBook’s DCOP interface to add the vCard entry to the KDE address book. KMail can then use these contacts for address completion while sending email.

To equip your KMail client with KBBDB, using a text editor, copy-paste the script into a plain file named kbbdb, place it under your home directory, and make it executable:

chmod +x ~/kbbdb

The script requires the Mail::Header and Mail::Address Perl modules. Under Debian, these are included in the libmailtools-perl package and can be obtained through apt-get:

apt-get install libmailtools-perl

Other distros with Perl installed can get them through Perl’s CPAN repository:

perl -MCPAN -e 'install Mail::Header Mail::Address'

The script also requires KDE’s KAddressBook be installed to append entries to. To check if everything’s hunky-dory, run the script from the command line:

./kbbdb

If the script runs silently without any errors, you’re ready to integrate it with KMail. The steps to create an email filter under KMail are outlined in the KBBDB help file:

perldoc kbbdb

Once set up, KBBDB can also be used to extract contact addresses from existing messages.