Message
instance has the following methods:
None
if there is no header matching name.
None
if there is
no header matching name.
getrawheader(name)
, but strip leading and trailing
whitespace (but not internal whitespace).
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*
'jack@cwi.nl (Jack Jansen)'
, then
m.getaddr('From')
will yield the pair
('Jack Jansen', 'jack@cwi.nl')
.
If the header contained
'Jack Jansen <jack@cwi.nl>'
instead, it would yield the
exact same result.
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.
XXX The current version of this function is not really correct. It yields bogus results if a full name contains a comma.
getheader
and parse it into a 9-tuple
compatible with time.mktime()
. If there is no header matching
name, or it is unparsable, return 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.
Message
instances also support a read-only mapping interface.
In particular: m[name]
is the same as m.getheader(name)
;
and len(m)
, m.has_key(name)
, m.keys()
,
m.values()
and m.items()
act as expected (and
consistently).
Finally, Message
instances have two public instance variables: