[sapug] twisted.mail versus imaplib
dt-sapug at handcraftedcomputers.com.au
Tue Aug 7 13:41:39 CEST 2007
John Steele Scott wrote:
> It's been it while since I last used imaplib, but what's clunky is its
> abstraction, or lack thereof. For some operations, it just returns the
> reply from the server, as a list of strings, and it is not documented what
> the list means (i.e. how the server reply has been split).
That's fair. When I last used it (1.6 era?) it exposed a lot of
the underlying detail, so working with the IMAP RFCs was pretty
much required. Looking at a 2.4 implementation doesn't look a
whole lot different from what I remembered.
> I can use it to
> do what I want, but it doesn't leave me feeling confident that it won't
> break depending on the phase of the moon (or, more likely, if I use a
> different IMAP server).
I think that provided you just work off the (documented by RFC) reply
codes you should be OK. The response should be the response from the
IMAP server (therefore list in the RFC) and should be one of either
OK, BYE, NO, and others which I've forgotten. Data following that
should be applicable to the response for the command (e.g. a SEARCH
would return a list of applicable message numbers if the response was
As for different IMAP servers, I think you're supposed to interrogate
the server to see what capabilities it supported, as not all servers
implemented all features. I certainly remember fairly wild differences
between Cyrus and UW.
> What I was hoping for was that someone would tell me that twisted.imap is
> a joy to work with, rock solid, and worth the effort. Or that it's not.
Ah, you'll need a twisted guru for that. I guess you could also
wrap the stdlib imap API with your own ("layer upon layer upon
"Bad kitty. Stop plotting evil."
More information about the sapug