Building .addressbook for mutt
I have been a user of mutt for more than two decades, utilizing it in various organizations where LDAP and AD were commonly employed. Mutt had the capability to interact with LDAP/AD through straightforward tools like ldap search, and everything was functioning smoothly until the shift to remote work became the norm. With the requirement to connect via VPN for corporate resource access, the process became considerably slower.
Initially, I considered switching to a web-based email system, but I eventually abandoned that idea and began exploring other options. None of them could match the functionality of mutt. The only solution was to persist with mutt and maintain an addressbook to store email addresses, a task that seemed excessive.
This approach was functional, but it necessitated the management of an additional script to create and keep the addressbook up to date. Subsequently, I decided to experiment with abook, a tool with a modest footprint and a user-friendly interface.
I ran
$ for i in ls; do cat $i | abook — add-email-quiet; done
on maildir. Within a few mins, abook managed to gather all the email addresses from the maildir. Upon a more thorough examination, I observed that abook had acquired duplicate entries, including email addresses of former colleagues and redundant IDs. Removing the duplicate entries proved to be a straightforward task.
Subsequently, I decided to execute ldap_search in order to create a reliable addressbook. It was a straightforward Python script that performed its task effectively, restoring mutt’s functionality.
However, I wasn’t entirely comfortable with the idea of relying on a script to build the addressbook, so I began searching for a simpler alternative once more. That’s when I discovered that my organization was using ‘centrifydc,’ which featured a useful utility known as ‘adquery user.’ This utility produced output similar to ‘/etc/passwd.’ I experimented with the following command:
$ adquery user | cut -d':' -f1,5 | awk -F':' 'BEGIN{cnt=1}{print "\n["++cnt"]" "\nname="$5,"\nemail="$1"@myorg.com";}' > ~/.abook/addressbook
It did the job in a matter of seconds. I obtained the desired results, and now I’m back to using mutt for work. I’m quite content with the current setup for the time being, and it’s working well. :-)