| Python Library Reference |
This module defines a class,Message, which represents an``email message'' as defined by the Internet standardRFC 2822.12.5 Such messagesconsist of a collection of message headers, and a message body. Thismodule also defines a helper classAddressList for parsingRFC 2822 addresses. Please refer tothe RFC for information on the specific syntax ofRFC 2822 messages.
Themailbox module provides classes to read mailboxes produced by various end-user mail programs.
This class can work with any input object that supports areadline() method. If the input object has seek and tellcapability, therewindbody() method will work; also, illegallines will be pushed back onto the input stream. If the input objectlacks seek but has anunread() method that can push back aline of input,Message will use that to push back illegallines. Thus this class can be used to parse messages coming from abuffered stream.
The optionalseekable argument is provided as a workaround forcertain stdio libraries in whichtell() discards buffereddata before discovering that thelseek() system calldoesn't work. For maximum portability, you should set the seekableargument to zero to prevent that initialtell() when passingin an unseekable object such as a a file object created from a socketobject.
Input lines as read from the file may either be terminated by CR-LF orby a single linefeed; a terminating CR-LF is replaced by a singlelinefeed before the line is stored.
All header matching is done independent of upper or lower case;e.g.m['From'],m['from'] andm['FROM'] all yield the same result.
None yields an empty list.)(None, None) is returned.(realname,email_address) and returns the stringvalue suitable for aTo: orCc: header. Ifthe first element ofpair is false, then the second element isreturned unmodified.'Mon, 20 Nov 1995 19:12:08 -0500'. If it succeeds in parsingthe date,parsedate() returns a 9-tuple that can be passeddirectly totime.mktime(); otherwiseNone will bereturned. Note that fields 6, 7, and 8 of the result tuple are notusable.None or a 10-tuple; the first 9 elements make up a tuplethat can be passed directly totime.mktime(), and the tenthis the offset of the date's timezone from UTC (which is the officialterm for Greenwich Mean Time). (Note that the sign of the timezoneoffset is the opposite of the sign of thetime.timezonevariable for the same timezone; the latter variable follows thePOSIX standard while this module followsRFC 2822.) If the inputstring has no timezone, the last element of the tuple returned isNone. Note that fields 6, 7, and 8 of the result tuple are notusable.None, assumelocal time. Minor deficiency: this first interprets the first 8elements as a local time and then compensates for the timezonedifference; this may yield a slight error around daylight savings timeswitch dates. Not enough to worry about for common use.See Also:
| Python Library Reference |