As I've said here before, I like reading my mail with mutt; it's true that it sucks less. For a while I've kept a local abook file with my contacts; or a least a partial list of people I normally send e-mails to. It was synchronized across several computers using Dropbox and more or less did the job, but lately I've tried to centralize this using Fastmail's servers. I've used this pretty handy Perl script to query Fastmail's LDAP servers, but this takes a second for every contact I want to e-mail. Not a lot of time, but not optimal either. Also, I don't have a local copy of my entire address book.

The other day I came across a pretty nice solution that doesn't involve coding almost anything on our end. It turns out that Fastmail offers an HTTP entry point for the entire address book as a single vcard file in the following URL:<username@domain.tld>/Default

This, combined with the fact that abook is able to convert between vcard and its own native format, gives us this script:



wget -q \
    --user \
    --password $PASS \
    -O $tmpfile

abook --convert \
    --informat vcard \
    --infile $tmpfile \
    --outformat abook \
    --outfile $destfile

rm $tmpfile
chmod 600 $destfile
mv $destfile ~/.abook/addressbook

Where, obviously, $PASS is whatever application password we have for this. And then we only have to set up a cron job to run this script from time to time tell mutt to use abook to locate addresses, as always:

set query_command = "abook --mutt-query '%s'"

There is no comment system. If you want to tell me something about this article, you can do so via e-mail or Mastodon.