[Email-SIG] question about the best way to check if an email is valid (RFC compliant)

R. David Murray rdmurray at bitdance.com
Wed Jul 6 14:08:55 CEST 2011


On Wed, 06 Jul 2011 11:53:43 +0200, xavier delannoy <xavier.delannoy at 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.

--David


More information about the Email-SIG mailing list