[Spambayes] imapfilter mangling headers!

Meyer, Tony T.A.Meyer at massey.ac.nz
Fri Apr 18 13:46:45 EDT 2003


> > >They're not dropped; they have apparently had all the
> > newlines removed!
> I *think* I should be able to write a script that will put these back
> into shape.  I'll have a good at duplicating the problem and 
> see what I can do.  I'll look at this now.

Now I'm not so sure :(.  Unfortunately (?) I can't duplicate this
behaviour on either of the imap servers I have available (NetMail and
Courier), so it's hard to tell what the messages would look like if I
did a IMAP fetch (i.e. is the \n there somewhere and could be retrieved,
or was it stripped at the append).

If it's not there then I don't think this can be done easily if at all.
The problem is finding the start of the header.  If it looks like this:
"X-Header1: blahX-Header2: xxx" then there's nothing distinctive between
the 'blah' and the 'X-' to search for.  (The only thing I can think of
is to search for all the proper headers (like Date and Subject), and
then search for the pattern r'X-([\w-]+):' and put newlines before that.
I suppose I could have a go at that - let me know if you want me to.

First, though, would be to check what is actually on the server.  You
could try running this and letting me know what comes back:

>>> import imaplib
>>> imap = imaplib.IMAP4(servername, serverport)
>>> imap.login(username, password)
>>> imap.select(unsure_folder_name, True)
>>> response = imap.fetch("1:1", "(RFC822)")
>>> imap.logout()
>>> print response # whole lot
>>> print response[1][0][1] # just the message text
>>> print len(response[1][0][1]) # to check for invisible characters

=Tony Meyer



More information about the Spambayes mailing list