Reading up on the FeedParser API, I understand it can parse an email message object and if it finds a non-compliant header format, it would populate the defects attribute of the object. I tried playing with this today, but I could not get it to populate the defects which I know to be there.
For example, here is the beginning part of the message header I'm feeding to FeedParser:
Received from geronimo.server11.kingtut.local ([172.16.50.50])
by ryu.objectgenerator.net (Lotus Domino Release 8.5.1FP5)
with ESMTP id 2012102117563555-21066 ;
Sun, 21 Oct 2012 17:56:35 +0800
Return-Path: <3ff.d.13239334.D893343-342613@bounce.objectgenerator.net>
The 1st line does not contain a colon separating the header field from the rest. Also, the 2nd line is not indented/folded properly.
Here is the code I'm testing:
>>> import email
>>> import email.parser
>>> file = open('bad.eml').read()
>>> bad_feed = email.parser.FeedParser()
>>> bad_feed.feed(file)
>>> msg_object = bad_feed.close()
>>> msg_object.defects
[]
>>>
I suspect that I'm not passing the 'file' in a proper manner to FeedParser. Could someone please point out what I'm doing wrong?