Cannot connect to IMAP server in Python 3.2

Steve Howell showell30 at yahoo.com
Thu Apr 5 03:33:10 EDT 2012


On Apr 5, 12:09 am, Steven D'Aprano <steve
+comp.lang.pyt... at pearwood.info> wrote:
> On Wed, 04 Apr 2012 22:13:55 -0700, Steve Howell wrote:
> > On Apr 4, 9:49 pm, Steven D'Aprano <steve
> > +comp.lang.pyt... at pearwood.info> wrote:
> >> I can connect to an IMAP server using Python 2.6:
>
> >> steve at runes:~$ python2.6
> >> Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5] on linux2
> >> Type "help", "copyright", "credits" or "license" for more
> >> information.>>> import imaplib
> >> >>> server = imaplib.IMAP4_SSL('xxxxx')
> >> >>> print server
>
> >> <imaplib.IMAP4_SSL instance at 0xb7183c4c>
>
> >> But when I try with Python 3.2, it just sits there until it times out:
>
> >> steve at runes:~$ python3.2
> >> Python 3.2.2 (default, Feb 29 2012, 18:11:33) [GCC 4.4.5] on linux2
> >> Type "help", "copyright", "credits" or "license" for more
> >> information.>>> import imaplib
> >> >>> server = imaplib.IMAP4('xxxxx', imaplib.IMAP4_SSL_PORT)
>
> >> Traceback (most recent call last):
> >> [...]
> >> socket.timeout: timed out
>
> >> What am I doing wrong?
>
> > Is it simply the wrong port?  (IMAP4_SSL_PORT vs. IMAP4_PORT)
>
> No, it is the correct port, 993.
>
> > How long do you wait before seeing the timeout?
>
> Indefinitely.
>
> > Have you tried print-debugging within your local copy of imaplib.py? The
> > code related to making the connection just wraps
> > socket.create_connection:
>
> I'm not going to start debugging the standard library until after I'm
> satisfied that I'm not doing something wrong.
>
> --
> Steven

What happens when you do this?

>>> import imaplib, socket
>>> socket.create_connection(('xxxxx', imaplib.IMAP4_SSL_PORT))



More information about the Python-list mailing list