Home | Trees | Indices | Help |
|
---|
|
email.message.Message --+ | PyzMessage
Inherit from email.message.Message. Combine get_mail_parts(), get_mail_addresses() and decode_mail_header() into a convenient object to access mail contents and attributes. This class also sanitize part filenames.
Note: Sample:
>>> raw='''Content-Type: text/plain; charset="us-ascii" ... MIME-Version: 1.0 ... Content-Transfer-Encoding: 7bit ... Subject: The subject ... From: Me <me@foo.com> ... To: A <a@foo.com>, B <b@foo.com> ... ... The text. ... ''' >>> msg=PyzMessage.factory(raw) >>> print 'Subject: %r' % (msg.get_subject(), ) Subject: u'The subject' >>> print 'From: %r' % (msg.get_address('from'), ) From: (u'Me', 'me@foo.com') >>> print 'To: %r' % (msg.get_addresses('to'), ) To: [(u'A', 'a@foo.com'), (u'B', 'b@foo.com')] >>> print 'Cc: %r' % (msg.get_addresses('cc'), ) Cc: [] >>> for mailpart in msg.mailparts: ... print ' %sfilename=%r sanitized_filename=%r type=%s charset=%s desc=%s size=%d' % ('*'if mailpart.is_body else ' ', mailpart.filename, mailpart.sanitized_filename, mailpart.type, mailpart.charset, mailpart.part.get('Content-Description'), 0 if mailpart.get_payload()==None else len(mailpart.get_payload())) ... if mailpart.is_body=='text/plain': ... payload, used_charset=decode_text(mailpart.get_payload(), mailpart.charset, None) ... print ' >', payload.split('\n')[0] ... *filename=None sanitized_filename='text.txt' type=text/plain charset=us-ascii desc=None size=10 > The text.
|
|||
|
|||
tuple |
|
||
list of tuple |
|
||
unicode |
|
||
unicode |
|
||
Inherited from Inherited from |
|
|||
email.message.Message |
|
||
PyzMessage |
|
|
|||
MailPart or None |
html_part the MailPart object that contains the HTML version of the message, None if the mail has not HTML content. |
||
list of MailPart |
mailparts list of MailPart objects composing the email, text_part and html_part are part of this list as are other attachements and embedded contents. |
||
MailPart or None |
text_part the MailPart object that contains the text version of the message, None if the mail has not text content. |
|
Use the appropriate parser and return a email.message.Message object (this is not a PyzMessage object)
|
Use the appropriate parser and return a PyzMessage object see smart_parser
|
Initialize the object with data coming from input.
|
return the name header value as an list of addresses tuple as returned by get_mail_addresses()
|
return the name header value as an address tuple as returned by get_mail_addresses()
|
return the RFC2047 decoded subject.
|
return decoded header name using RFC2047. Always use this function to access header, because any header can contain invalid characters and this function sanitize the string and avoid unicode exception later in your program. EVEN for date, I already saw a "Center box bar horizontal" instead of a minus character.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Jan 3 19:15:58 2013 | http://epydoc.sourceforge.net |