By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,742 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,742 IT Pros & Developers. It's quick & easy.

Using imaplib module with GMAIL's IMAP - hangs

P: n/a
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/...y?answer=78799

Thanks for any help.

-Greg

Nov 8 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Nov 8, 11:41 am, "gregpin...@gmail.com" <gregpin...@gmail.com>
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/...y?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

Nov 8 '07 #2

P: n/a
On Nov 8, 1:52 pm, Jason <tenax.racc...@gmail.comwrote:
On Nov 8, 11:41 am, "gregpin...@gmail.com" <gregpin...@gmail.com>
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/...y?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

Thanks! That worked. You're a gem.

-Greg

Nov 8 '07 #3

P: n/a
On Nov 8, 1:52 pm, Jason <tenax.racc...@gmail.comwrote:
On Nov 8, 11:41 am, "gregpin...@gmail.com" <gregpin...@gmail.com>
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/...y?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

Nov 8 '07 #4

P: n/a
On Nov 8, 2:22 pm, "gregpin...@gmail.com" <gregpin...@gmail.com>
wrote:
On Nov 8, 1:52 pm, Jason <tenax.racc...@gmail.comwrote:
On Nov 8, 11:41 am, "gregpin...@gmail.com" <gregpin...@gmail.com>
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/...y?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

Nov 8 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.