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:
This, combined with the fact that abook is able to convert between vcard and its own native format, gives us this script:
#!/bin/bash tmpfile=$(mktemp) destfile=$(mktemp) wget -q https://email@example.com/Default \ --user firstname.lastname@example.org \ --password $PASS \ -O $tmpfile abook --convert \ --informat vcard \ --infile $tmpfile \ --outformat abook \ --outfile $destfile rm $tmpfile chmod 600 $destfile mv $destfile ~/.abook/addressbook
$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'"