[Email-SIG] question about the best way to check if an email is valid (RFC compliant)
xavier delannoy
xavier.delannoy at cloudmark.com
Wed Jul 6 11:53:43 CEST 2011
Hi,
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:
# Parse the received email
try:
received_email = email.message_from_string(args)
except email.errors.MessageError, msg:
self.ok((False, msg), msg)
I test with an invalid email (for example, with a missing closed
boundary), and no exception is raised. The email lib fixes the issue.
Is there a way to tell the email lib to not modify the email, and raise
an exception ?
Regards,
-- Xavier
QA Engineer at Cloudmark Labs.
More information about the Email-SIG
mailing list