2002-04-10 18:01:31 -03:00
|
|
|
|
# Copyright (C) 2001,2002 Python Software Foundation
|
2001-09-23 00:17:28 -03:00
|
|
|
|
# Author: barry@zope.com (Barry Warsaw)
|
|
|
|
|
|
|
|
|
|
"""A package for parsing, handling, and generating email messages.
|
|
|
|
|
"""
|
|
|
|
|
|
2002-09-25 19:07:50 -03:00
|
|
|
|
__version__ = '2.4'
|
2001-09-23 00:17:28 -03:00
|
|
|
|
|
2002-04-10 18:01:31 -03:00
|
|
|
|
__all__ = ['Charset',
|
|
|
|
|
'Encoders',
|
2001-09-23 00:17:28 -03:00
|
|
|
|
'Errors',
|
|
|
|
|
'Generator',
|
2002-04-10 18:01:31 -03:00
|
|
|
|
'Header',
|
2001-09-23 00:17:28 -03:00
|
|
|
|
'Iterators',
|
2001-10-09 16:14:59 -03:00
|
|
|
|
'MIMEAudio',
|
2001-09-23 00:17:28 -03:00
|
|
|
|
'MIMEBase',
|
2001-10-09 16:14:59 -03:00
|
|
|
|
'MIMEImage',
|
|
|
|
|
'MIMEMessage',
|
|
|
|
|
'MIMEText',
|
2001-09-23 00:17:28 -03:00
|
|
|
|
'Message',
|
|
|
|
|
'Parser',
|
|
|
|
|
'Utils',
|
2002-04-10 18:01:31 -03:00
|
|
|
|
'base64MIME',
|
|
|
|
|
'quopriMIME',
|
2001-09-23 00:17:28 -03:00
|
|
|
|
'message_from_string',
|
|
|
|
|
'message_from_file',
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
2001-10-04 14:05:11 -03:00
|
|
|
|
|
2002-09-25 19:07:50 -03:00
|
|
|
|
# Some convenience routines. Don't import Parser and Message as side-effects
|
|
|
|
|
# of importing email since those cascadingly import most of the rest of the
|
|
|
|
|
# email package.
|
|
|
|
|
def message_from_string(s, _class=None, strict=0):
|
|
|
|
|
from email.Parser import Parser
|
|
|
|
|
if _class is None:
|
|
|
|
|
from email.Message import Message
|
|
|
|
|
_class = Message
|
|
|
|
|
return Parser(_class, strict=strict).parsestr(s)
|
2001-09-23 00:17:28 -03:00
|
|
|
|
|
2002-09-25 19:07:50 -03:00
|
|
|
|
def message_from_file(fp, _class=None, strict=0):
|
|
|
|
|
from email.Parser import Parser
|
|
|
|
|
if _class is None:
|
|
|
|
|
from email.Message import Message
|
|
|
|
|
_class = Message
|
|
|
|
|
return Parser(_class, strict=strict).parse(fp)
|