473,246 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

Using imaplib module with GMAIL's IMAP - hangs

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
4 11735
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Colin Brown | last post by:
The Python 2.3 documentation in imaplib says: Internaldate2tuple( datestr) Converts an IMAP4 INTERNALDATE string to Coordinated Universal Time. Returns a time module tuple. Time2Internaldate(...
4
by: Raghul | last post by:
Hi Friends, I am doing project in python.I am new to this. My problem is I want to move the mail message to other folder in the mail using imaplib (E.g) I want to move a message from the inbox...
2
by: Raghul | last post by:
What is message_set in the python documentation for copy in imaplib? Is they referring message set to the particular mail message in my inbox or something else. copy( message_set,...
0
by: Wolfgang Kohnen | last post by:
Hello out there! I am new to python and so far I like it a lot. Now I want to create some IMAP mailboxes on my cyrus imapd, with quotas and each user should be subscribed to her/his own spam...
5
by: Antoon Pardon | last post by:
This little program gives IMO a strange result. import imaplib user = "cpapen" cyr = imaplib.IMAP4("imap.vub.ac.be") cyr.login("cyrus", "cOn-A1r") rc, lst = cyr.list('""', "user/%s/*" %...
1
by: csselo | last post by:
Hi I am looking for a code sample which searches mail by date with imaplib example: get email from 01.01.2007 to now how can I change imaplib search parameters?
0
by: aspineux | last post by:
setacl and getacl look to be already "Cyrus" specific (according the doc), why not to extend imaplib a little bit more ? Here are some code I wrote and tested to support cyrus "expire" that...
0
by: Igor V. Rafienko | last post by:
Hi, I was wondering if anyone had a suggestion for the following issue. I would like to talk to an IMAP-server, imaplib being the tool of choice, of course. Unfortunately it may happen that...
3
by: KeefTM | last post by:
Hello, I am getting an odd error when trying to establish an IMAP connection: File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/ imaplib.py", line 904, in _get_response...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.