<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>> <br>> Ideally, I'd love to see a snipped which is able to log into an imap <br>> 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 = '?'<br>password = '?'<br>servername = '?'<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('','*')<br> d.addCallback(mailboxes)<br> return d<br><br>def connected(proto):<br> print "connected", proto<br>
d = proto.login(username, password)<br> d.addCallback(loggedin, proto)<br> return d<br><br>def failed(f):<br> print "failed", 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'll want to understand that.<br></blockquote><br>