Re: Using imaplib module with GMAIL's IMAP - hangs



On Nov 8, 2:22 pm, "gregpin...@xxxxxxxxx" <gregpin...@xxxxxxxxx>
wrote:
On Nov 8, 1:52 pm, Jason <tenax.racc...@xxxxxxxxx> wrote:



On Nov 8, 11:41 am, "gregpin...@xxxxxxxxx" <gregpin...@xxxxxxxxx>
wrote:

I'm trying to get a list of messages from GMAIL using it's new IMAP
access.

So far I've tried running this command but it just hangs. Any ideas?

import imaplib
M=imaplib.IMAP4('imap.gmail.com',993)

I figured that's the first line to run from this example:http://docs.python.org/lib/imap4-example.html

Here are the configuration settings GMAIL says to use:https://mail.google.com/support/bin/answer.py?answer=78799

Thanks for any help.

-Greg

Well, Google states that it's using SSL. You're not using the SSL
with your example code. Take a look in the imaplib module. At least
under Python 2.5, there's also an IMAP4_SSL class:

import imaplib
mail = imaplib.IMAP4_SSL('imap.gmail.com', 993)

That worked for me. I could then use the login method to log into the
mail server.

--Jason

Followup question. My ultimate goal is to get all messages with a
certain GMAIL label. I'm going under the assumption labels will
appear as folders over IMAP. Any idea how to access folders with
IMAP?

-Greg


Figured it out. Just do mail.select('label')

GMAIL does treat labels as folders.

-Greg

.



Relevant Pages

  • Re: Running a dovecot IMAPS server
    ... Suppose now you start dovecot IMAP on computer X. ... mail client on Y, or through a mail client running on that X computer? ... and creating folders "family", etc, with the kmail GUI. ...
    (Fedora)
  • Re: KMail + IMAP - help urgently sought
    ... They shouldn't be, except for local folders. ... Heigh ho is it possible Timothy is using the IMAP server's store dir as ... unless he is actually viewing it on the server. ...
    (Fedora)
  • Re: Sharing my mail with my laptop
    ... able to look at my mail folders from either host, ... My understanding is that with imap I can do ... now I want my laptop to be able to access my email also ... my mail server is a FreeBSD machine running an old release ...
    (Fedora)
  • Re: Q re moving email to diff machine
    ... Start dovecot, set up an IMAP acount on your client pointing to ... it, create some folders, select your messages, drag to the new ... IMAP clients from the same box or anywhere else. ...
    (Fedora)
  • Re: Mail handling [local IMAP]
    ... Thunderbird to fetch mail from your ISP then filter it into IMAP ... Which specific IMAP server have you installed on your computer? ... eg procmail) delivering to its folders. ...
    (uk.comp.os.linux)