Post details: IMAP Gmail ennui

10/31/05

Permalink 09:21:36 pm, Categories: Python, 245 words   English (US)

IMAP Gmail ennui

So this past week or so I've been pretty bored. With school out it is rather lame. I decided to torture myself further and try hacking again at making an IMAP interface to Gmail.

I didn't really get much further along, but I did manage to get it working with Thunderbird:

I don't really recommend using this at all. It's more of a proof of concept and something to keep me busy. The code is absolutely horrible. It fetches ALL mail from your Gmail inbox at startup no matter what. I found that the hardest thing for me to do and what took the most time (and probably is buggy as hell) was trying to parse a string such as:

a0004 FETCH 1:1 (UID FLAGS INTERNALDATE RFC822.SIZE BODY.PEEK[HEADER.FIELDS (DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE IN-REPLY-TO REPLY-TO LINES X-LABEL)])

The parentheses and brackets can be nested, so above might also have '.. FLAGS (\Seen) ..' etc. That's what makes this difficult. I'd appreciate any algorithms :). I also got to see how the various IMAP clients work. I found that mutt is the cleanest IMAP client. I could not get it working with Apple Mail and may try again later. I probably spent more time looking at tcpdumps when sane people would look at the IMAP RFC :). Go here if you are feeling brave. Don't blame me if you lose all your mail. I don't see how that can happen, but you've been warned.

Comments, Pingbacks:

Comment from: Marv [Visitor] · http://www.netzwerk-aktiv.com/
Hi,
I am developing an IMAP(s) mail reader for the XBOX using python.

I was trying to get imapgmail.py to work with my prog, but unfortunately I got some errors.

In line 298 and 306 you append the dataset to dataitems while inserting "\r\n" 2 times, but increasing the data only by 3 ("size + 3"). I changed this to "size + 4" and my parsing errors with Python's imaplib went away...
It works now and I can check the GMail emails via the XBOX.
Just wanted to let you know.
Good work, anyway, and many thanks!

Greetings from Germany,
Marv
Permalink 02/19/06 @ 14:32
Comment from: Aaron [Visitor] · http://blogofaaron.com
How do you use the code to get GMail via IMAP.
Permalink 05/04/06 @ 04:17
Comment from: Matthew [Visitor] · http://www.braintube.com
A python/twisted based IMAP interface to gmail.

http://www.butterfat.net/igmail/
Permalink 09/11/06 @ 18:19

Leave a comment:

 
 

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a

Viraj's Weblog

This is my personal blog. The views expressed on these pages are mine alone and not those of my employer.

August 2010
Mon Tue Wed Thu Fri Sat Sun
<<  <   >  >>
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          

Search

Categories


Misc

Syndicate this blog XML

What is RSS?

powered by
b2evolution