On 07/06/2011 02:08 PM, R. David Murray wrote:
On Wed, 06 Jul 2011 11:53:43 +0200, xavier 
delannoy<xavier.delan...@cloudmark.com>  wrote:
I use the python email library for an Automation Test Framework. The
framework test a Mail Transfert Agent. I notice that the "email" library
silently fix a lot of MIME errors. I can understand this behaviour, but
I need to validate that the email sent by the MTA are correct.
I wonder if there's a way to use the python MIME Parser more
"aggressively" (without modifying the email) and raise and exception as
soon as an error is detected.

Here's my needs and an extract of my python:

Not at the moment.  You can check the defects attribute afterward to
see if there were any detected errors, though.

In email6 (planned for python 3.3) we will be providing a facility for
doing the raise immediately.  I don't know what you mean by leave
the message unmodified, though, since the input string is already
unmodified, and you won't get a message object when an error is raised.


If an error is raised, and if I won't get a message object, then I'm
fine. But with Python 2.7.1, I get a message object and the attribute
defects is empty.

In the attachment you will find:
  - orig.eml : an email with an error. The boundary
"000101020201080900040301" isn't closed
  - after_parsing.eml: same email after calling email.message_from_file()
The boundary is now closed. And the defects attribute is empty
  - test.py: python script to reproduce.

-- Xavier


--David

Attachment: sample.tgz
Description: application/compressed-tar

_______________________________________________
Email-SIG mailing list
Email-SIG@python.org
Your options: 
http://mail.python.org/mailman/options/email-sig/archive%40mail-archive.com

Reply via email to