473,395 Members | 1,452 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,395 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 11749
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.