internet data handling and encoding email package the email package provides wide variety of functions and objects for representingparsing and manipulating email messages encoded according to the mime standard covering every detail of the email package is not practical herenor would it be of interest to most readers thusthe rest of this section focuses on two common practical problems--parsing email messages in order to extract useful information and creating email messages so that they can be sent using the smtplib module parsing email at the top levelthe email module provides two functions for parsing messagesmessage_from_file(fparses an email message read from the file-like object which must be opened in text mode the input message should be complete mime-encoded email message including all headerstextand attachments returns message instance message_from_string(strparses an email message by reading an email message from the text string str returns message instance message instance returned by the previous functions emulates dictionary and supports the following operations for looking up message dataoperation description returns the value of header name returns list of all message header names returns list of message header values returns list of tuples containing message header names and values get(name [,def]returns header value for header name def specifies default value to return if not found len(mreturns the number of message headers str(mturns the message into string the same as the as_string(method name in returns true if name is the name of header in the message [namem keys( values( items(in addition to these operatorsm has the following methods that can be used to extract informationm get_all(name [default]returns list of all values for header with name name returns default if no such header exists get_boundary([default]returns the boundary parameter found within the 'content-typeheader of message typically the boundary is string such as '=============== ==that' used to separate the different subparts of message returns default if no boundary parameter could be found lib fl ff