[Twisted-Python] twisted.mail.imap4.MessageSet object & imap4 server example
![](https://secure.gravatar.com/avatar/a94b04abadb5fc282fd17eb8813139a6.jpg?s=120&d=mm&r=g)
Hi! 1. I don't understand how to use this object. When the fetch method is called, this object is passed containing the requested messages which you then return, right? But is there any easy way to just iterate through it and get the requested UIDis, even if LAST is not set. 2. Where could I find some IMAP4 server examples? Thank you. Regards, Sebastjan
![](https://secure.gravatar.com/avatar/6cd37343ce1da139b1d2ff5ee717f5d5.jpg?s=120&d=mm&r=g)
Sebastjan Trepca wrote:
MessageSet is iterable; you can say "for uid in MessageSet: doStuff()". You have to set MessageSet.last yourself though if it wasn't specified by the client; set it to the value of the last uid (or sequence ID) available. if not messageSet.last: messageSet.last = self.getUIDNext()-1 will probably do the trick.
2. Where could I find some IMAP4 server examples?
You can look at the Hep IMAP server code here: http://svn.yarnproject.org/websvn/filedetails.php?repname=hep&path=%2Fhep%2Fservices%2Fimap.py&rev=0&sc=0 It might be a little hard to understand as it's using the Hep server and Yarn to translate between IMAP and other protocols, but hopefully you'll find it helpful. Abe
![](https://secure.gravatar.com/avatar/6cd37343ce1da139b1d2ff5ee717f5d5.jpg?s=120&d=mm&r=g)
Sebastjan Trepca wrote:
MessageSet is iterable; you can say "for uid in MessageSet: doStuff()". You have to set MessageSet.last yourself though if it wasn't specified by the client; set it to the value of the last uid (or sequence ID) available. if not messageSet.last: messageSet.last = self.getUIDNext()-1 will probably do the trick.
2. Where could I find some IMAP4 server examples?
You can look at the Hep IMAP server code here: http://svn.yarnproject.org/websvn/filedetails.php?repname=hep&path=%2Fhep%2Fservices%2Fimap.py&rev=0&sc=0 It might be a little hard to understand as it's using the Hep server and Yarn to translate between IMAP and other protocols, but hopefully you'll find it helpful. Abe
participants (2)
-
Abe Fettig
-
Sebastjan Trepca