<div>Phil,<br><br>Much obliged. <br><br>Was able to isolate and confirm that the real issue is that login is hanging for some reason, and causing the timeout message. I suspect SSL/TLS issues, which at least gives me a decided place to start investigating.<br>
<br>Thanks again for the code, it was sanity inducing to say the least. ;)<br><br><br>Phil Mayers wrote: <br></div><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
Pywinder Singh wrote:<br>&gt; <br>&gt; Ideally, I&#39;d love to see a snipped which is able to log into an imap <br>&gt; server and gets a list of mailboxes.  If the example on the site works <br><br>Here you go:<br><br>#!/usr/bin/python<br>
<br>from twisted.internet import reactor, protocol, defer<br>from twisted.mail import imap4<br><br># change these...<br>username = &#39;?&#39;<br>password = &#39;?&#39;<br>servername = &#39;?&#39;<br><br>def mailboxes(list):<br>
     for flags,sep,mbox in list:<br>         print mbox<br><br>def loggedin(res, proto):<br>     d = proto.list(&#39;&#39;,&#39;*&#39;)<br>     d.addCallback(mailboxes)<br>     return d<br><br>def connected(proto):<br>     print &quot;connected&quot;, proto<br>
     d = proto.login(username, password)<br>     d.addCallback(loggedin, proto)<br>     return d<br><br>def failed(f):<br>     print &quot;failed&quot;, f<br>     return f<br><br>def done(_):<br>     reactor.callLater(0, reactor.stop)<br>
<br>def main():<br>     c = protocol.ClientCreator(reactor, imap4.IMAP4Client)<br>     d = c.connectTCP(servername, 143)<br>     d.addCallbacks(connected, failed)<br>     d.addBoth(done)<br><br>reactor.callLater(0, main)<br>
reactor.run()<br><br><br>This example makes use of deferred chaining i.e. returning a deferred <br>from a callback handler, so you&#39;ll want to understand that.<br></blockquote><br>