[Twisted-Python] Trouble with example imap client on unread messages
Thomas HERVE
therve at free.fr
Fri Jul 8 02:36:32 MDT 2005
Quoting Andy Gayton <andy at thecablelounge.com>:
> I'm having trouble running Twisted/doc/mail/examples/imap4client.py
> on imap folders which have unread messages. When the client issues:
>
> proto.fetchSpecific('1:*',
> headerType='HEADER.FIELDS',
> headerArgs=['SUBJECT']
> )
>
> My server is returning:
>
> * 243 FETCH (BODY[HEADER.FIELDS ("SUBJECT")] {47}
> Subject: DELIVERY REPORTS ABOUT YOUR E-MAIL
>
> )
> * 244 FETCH (BODY[HEADER.FIELDS ("SUBJECT")] {42}
> Subject: AW: [syslinux] bug(?) in 2.11
>
> )
> * 244 FETCH (FLAGS (\Seen))
The problem I see is here : why does the server had this line ? It
doesn't seem
to be an answer, but more the consequence of the fetch (which mark messages as
seen). This message should appeared *after* fetch called... Maybe Bincimap is
too fast :).
You could try this instead (which don't mark message seen) :
proto.fetchSpecific('1:*',
headerType='HEADER.FIELDS',
headerArgs=['SUBJECT'],
peek=True
)
> 243 is a previously read message, 244 is an unread message.
>
> The callback for the above fetchSpecific call is receiving:
>
> { 243 : [['BODY', ['HEADER.FIELDS', ['SUBJECT']], 'Subject: DELIVERY
> REPORTS ABOUT YOUR E-MAIL\r\n\r\n']], 244 : [['FLAGS', ['\\Seen']]] }
>
> ie, I'm not getting the subject for unread messages.
Well actually it's logical, because Twisted parses result in a dictionnary so
you have :
res[243] = < subject >, then res[244] = < subject >, but res[244] = < flags >
which overrides previous value.
> Just wondering if this is a problem at twisted's end (is it
> incorrectly reducing the server response for 244 to [['FLAGS',
> ['\\Seen']]]?), my imap server (is it incorrect that my server is
> including the extra * 244 FETCH (FLAGS (\Seen)) line ? I'm using
> BincIMAP v1.2.12) or me :) (am I running something wrong here?)
I would say it's server fault, but if Twisted can cope with it it's better.
--
Thomas
More information about the Twisted-Python
mailing list