rootmsg is the root of the object tree to iterate line-by-line over.
The mimelib.address module exports some of the more useful address parsing related functions from rfc822. They are mostly provided for convenience.
To:
or Cc:
- into its constituent
``realname'' and ``email address'' parts. Returns a tuple of that
information, unless the parse fails, in which case a 2-tuple of
(None, None)
is returned.
(realname, email_address)
and returns the string value suitable
for a To:
or Cc:
header. If the first element of
pair is false, then the second element is returned unmodified.
Module address also provides the following useful function:
parseaddr()
. fieldvalues is a sequence of header field
values as might be returned by Message.getall(). Here's a
simple example that gets all the recipients of a message:
from mimelib.address import getaddresses tos = msg.getall('to') ccs = msg.getall('cc') resent_tos = msg.getall('resent-to') resent_ccs = msg.getall('resent-cc') all_recipients = getaddresses(tos + ccs + resent_tos + resent_ccs)
The mimelib.date module exports some other useful date related functions from rfc822. They are mostly provided for convenience.
'Mon, 20 Nov 1995 19:12:08 -0500'
. If it succeeds in parsing
the date, parsedate() returns a 9-tuple that can be passed
directly to time.mktime(); otherwise None
will be
returned. Note that fields 6, 7, and 8 of the result tuple are not
usable.
None
or a 10-tuple; the first 9 elements make up a tuple
that can be passed directly to time.mktime(), and the tenth
is the offset of the date's timezone from UTC (which is the official
term for Greenwich Mean Time). (Note that the sign of the timezone
offset is the opposite of the sign of the time.timezone
variable for the same timezone; the latter variable follows the
POSIX standard while this module follows RFC 822.) If the input
string has no timezone, the last element of the tuple returned is
None
. Note that fields 6, 7, and 8 of the result tuple are not
usable.
None
, assume
local time. Minor deficiency: this first interprets the first 8
elements as a local time and then compensates for the timezone
difference; this may yield a slight error around daylight savings time
switch dates. Not enough to worry about for common use.
See About this document... for information on suggesting changes.