Tag Archives: gmail

Using your Gmail contacts in Mutt

I really enjoy using Mutt as my email client. However, sometimes I have to log
into my Gmail account to view my contacts. Tired of this, I exported my Gmail
contacts and imported them into abook.

Now I can view my Gmail contacts in Mutt.

Here’s how I did it:

(Sorry, no cut and paste instructions.)

* Export your Gmail contacts in the vcard format

* Download the abook source and patch it with the vcard diff (available on the abook website). NOTE: you can also use the vcard2abook.pl script available in the contrib/ dir in the source.

* Import your contacts by invoking abook with the following options: ‘–convert –informat vcard –infile INPUT.vcf –outformat abook –outfile ~/.abook/addressbook’

* Configure your abook (see `man abookrc`). abook has sane defaults so your config file can be very minimal:

set www_command=elinks
set add_email_prevent_duplicates=true

* Next, configure mutt to interact with abook. I added the following lines to my muttrc
set query_command=”abook –mutt-query ‘%s'”
macro index,pager A “abook –add-email-query” “add the sender to the address book”

That’s all :). Press A while in Mutt to add a contact and Q to query the address book.

Setting up IMAP on Mutt

After receiving my HP 2710p, I decided to use IMAP instead of POP for
managing my email.  As you know, Mutt is my primary MUA (mail user agent).

The benefits of this setup are obvious: synchronous email (both on the computer
and on the webserver), space savings, and less programs to configure.

In this example, I’ll be setting up an IMAP connection to Gmail from Mutt.

First download the certificate of the organisation that is providing the IMAP
service.  Gmail uses “ThawtePremiumServerCA.crt”.  Make sure you compare your
checksum with the one provided by the Thawte Certificate Authority.  Place this
certificate in “~/.certs”.

Next, configure a profile for use with the IMAP connection.  I have an
engineering account with my university as well as a Gmail account, so I need two
profiles.  The Mutt profile is simple.

# email@gmail.com

source ~/.muttrc
set imap_user="email@gmail.com"
set folder="imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed=+"[Gmail]/Drafts"
set smtp_url="smtp://email@smtp.gmail.com:587/"

Note: My ~/.muttrc” contains global configuration values.

Next, simply add aliases for each profile that you create.  For example:

[ ... ]
alias mutt1="mutt -F ~/.mutt/muttrc_gmail"
alias mutt2="mutt -F ~/.mutt/muttrc_college"

To use your configuration, issue “mutt1” or “mutt2” at the prompt.