Pywinder Singh wrote: > > Ideally, I'd love to see a snipped which is able to log into an imap > server and gets a list of mailboxes. If the example on the site works
Here you go: #!/usr/bin/python from twisted.internet import reactor, protocol, defer from twisted.mail import imap4 # change these... username = '?' password = '?' servername = '?' def mailboxes(list): for flags,sep,mbox in list: print mbox def loggedin(res, proto): d = proto.list('','*') d.addCallback(mailboxes) return d def connected(proto): print "connected", proto d = proto.login(username, password) d.addCallback(loggedin, proto) return d def failed(f): print "failed", f return f def done(_): reactor.callLater(0, reactor.stop) def main(): c = protocol.ClientCreator(reactor, imap4.IMAP4Client) d = c.connectTCP(servername, 143) d.addCallbacks(connected, failed) d.addBoth(done) reactor.callLater(0, main) reactor.run() This example makes use of deferred chaining i.e. returning a deferred from a callback handler, so you'll want to understand that. _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python