mutt and your gmail contacts

I was looking for contact sync alternatives for my BlackBerry and came across an announcement that Google Sync for the BlackBerry now includes two-way contact sync. I decided that was good enough reason to start using my GMail contacts, something I never did before since I don’t use the GMail web UI very often.

Other than the BlackBerry I use mutt as a mail user agent. I have a few scripts already written to hook mutt into GMail’s outgoing mail server and Google Calendar so I figured if I was going to use my GMail contacts on the BlackBerry I should shim it into mutt’s contacts as well. In my CVS Web is a small Python script that I wrote to do just that.

If anyone finds any of this useful I’d love to hear about it. Ditto for feature requests, bug reports, or patches.

Tags: , , ,

5 Responses to “mutt and your gmail contacts”

  1. Erik says:

    I set up your script but each query I submit returns “No Contacts Found”.

  2. Erik says:

    Looks like I solved this by editing the max_results. However, contacts with multiple email addresses don’t seem to be handled properly. The script only seems to return the primary email address for each contact, which is not as useful if you have contacts with multiple addresses.

  3. Erik says:

    Nevermind, the max_results thing was a red herring. There was actually an indentation issue. I’ve emailed you a patch that fixes this. I also sent you another patch that will make the script return all matches to the query, rather than just ones that are the primary email address for a given contact.

  4. Richard says:

    This patch looks if there is a group which is equal to the search argument and returns all addresses in that group. I like it since I use groups a lot.
    I hope indentation stays ok.

    +++ mutt-gcontact2.py 2009-11-25 23:27:54.831775946 +0100
    @@ -1,4 +1,4 @@
    -#!/usr/local/bin/python -tt
    +#!/usr/bin/python -tt

    “”" mutt-gcontacts.py (c) 2008 Matthew John Ernisse

    @@ -68,6 +68,7 @@
    username = “”
    password = “”
    search = “”
    + group_name = “”

    for o, a in opts:
    if o == “-u”:
    @@ -97,8 +98,16 @@
    # fetch the user’s contacts.
    contacts = []
    offset = 1
    + groups = {}
    + group_feed = g.GetGroupsFeed()
    + for i in group_feed.entry:
    + groups[i.title.text] = i.id.text
    while True:
    - q = gdata.contacts.service.ContactsQuery()
    + try:
    + q = gdata.contacts.service.ContactsQuery(group=groups[search])
    + search = “@”
    + except:
    + q = gdata.contacts.service.ContactsQuery()
    q.max_results = 20
    q.start_index = offset
    c = 0
    @@ -111,6 +120,7 @@

    c += 1

    +
    if c == 20:
    offset += 20
    else:

  5. mernisse says:

    It looks like wordpress mangled the patch pretty hard, I tried to clean it up but alas it seems to be a losing battle. If you would be so kind as to drop a copy of the patch to mernisse at ub3rgeek.net that would be awesome and I’ll happily merge it. Thanks!

Leave a Reply