A Message instance has the following methods:
) |
line) |
None
(implying that parsing should stop here and the
line be pushed back on the input stream). It is sometimes useful to
override this method in a subclass.
line) |
line) |
True
if the given line should be ignored entirely, just skipped.
By default this is a stub that always returns False
, but you can
override it in a subclass.
name) |
name) |
None
if there is no header matching name.
name) |
None
if there is
no header matching name.
name[, default]) |
getrawheader(name)
, but strip leading and trailing
whitespace. Internal whitespace is not stripped. The optional
default argument can be used to specify a different default to
be returned when there is no header matching name.
name[, default]) |
name) |
(full name, email address)
parsed
from the string returned by getheader(name)
. If no
header matching name exists, return (None, None)
;
otherwise both the full name and the address are (possibly empty)
strings.
Example: If m's first From: header contains the
string '[email protected] (Jack Jansen)'
, then
m.getaddr('From')
will yield the pair
('Jack Jansen', '[email protected]')
.
If the header contained
'Jack Jansen <[email protected]>'
instead, it would yield the
exact same result.
name) |
getaddr(list)
, but parses a header
containing a list of email addresses (e.g. a To: header) and
returns a list of (full name, email address)
pairs
(even if there was only one address in the header). If there is no
header matching name, return an empty list.
If multiple headers exist that match the named header (e.g. if there are several Cc: headers), all are parsed for addresses. Any continuation lines the named headers contain are also parsed.
name) |
None
.
Date parsing appears to be a black art, and not all mailers adhere to the standard. While it has been tested and found correct on a large collection of email from many sources, it is still possible that this function may occasionally yield an incorrect result.
name) |
None
.
Message instances also support a limited mapping interface.
In particular: m[name]
is like
m.getheader(name)
but raises KeyError if
there is no matching header; and len(m)
,
m.get(name[, default])
,
m.has_key(name)
, m.keys()
,
m.values()
m.items()
, and
m.setdefault(name[, default])
act as
expected, with the one difference that setdefault() uses
an empty string as the default value. Message instances
also support the mapping writable interface m[name] =
value
and del m[name]
. Message objects do not
support the clear(), copy(), popitem(), or
update() methods of the mapping interface. (Support for
get() and setdefault() was only added in Python
2.2.)
Finally, Message instances have some public instance variables:
mbox
-style mailbox file.
See About this document... for information on suggesting changes.