Email and MIME Modules

email.errors

Defines exceptions and defect types for email parsing and construction. A tolerant parser may retain malformed input and report defects instead of raising immediately. Applications must decide which defects are acceptable before trusting parsed content.

Formal Syntax & Structure

python syntaxpython
import email.errors

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
from email import policyfrom email.parser import BytesParsermessage = BytesParser(policy=policy.default).parsebytes(b"Bad header\r\n\r\nbody")print(type(message.defects[0]).__name__)
Python Reference