Skip to content

Address Book Examples

Robert Winkler edited this page Feb 3, 2022 · 3 revisions

Here are some examples how users configured their address books. The most basic examples can also be found in the official docs. But maybe you can find some more specialized ways to do it here :)

Custom shell script with mutt like output

I (@lucc) use a custom shell script which queries email addresses from several sources much like the old lbdb. But my script also caches the email addresses in order to be fast even with slow backends. It is published here

The alot config for this is strait forward, because the script uses mutt's format.

[[[abook]]]
type = shellcommand
command = abq.sh
regexp = '^(?P<email>[^@]+@[^\t]+?) *\t *(?P<name>[^\t]+)(\t.*)?'

Import contact "From: address [email protected]" to abook

The abook integration of alot is great, but manually adding new contacts is tedious.

The following hook extracts the contact of a sender and imports it to the default abook addressbook:

add_to_abook.py

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import os
from email import policy
from email.parser import BytesParser

raw = sys.stdin.buffer.read()

msg = BytesParser(policy=policy.default).parsebytes(raw)

text = str(msg.get('From'))

myCmd = 'echo "From: ' + text + '"| abook --add-email-quiet'

print(myCmd)
os.system(myCmd) 

in the config:

[bindings]
   x = pipeto /home/rob/.config/alot/add_to_abook.py

Behaviour: With the email open (tread mode), press x to e(x)tract the Sender name/ address (From: ) and to import it to the abook. This hook should work on platforms that support the command line syntax: echo "From: Donald D. Duck <[email protected]>" | abook --add-email-quiet.

Contact management with khard https://github.com/scheibler/khard/

Advantages

Migration of abook contacts

Autocompletion in alot

Entry in the .config/alot/config (for each account):

[[account]] 
        ...
        [[[abook]]]
               type = shellcommand
               command = khard email --remove-first-line --parsable
               regexp = '^(?P<email>[^@]+@[^\t]+)\t+(?P<name>[^\t]+)'