Emails
An e-mail message consists of headers (for example, From, To, Subject, etc.) and the main body (see RFC 822, section 3.1 ).
By default, the body of the message is treated as plain ASCII text. MIME ( RFC 2045 , RFC 2046 , RFC 2047 , RFC 2048 , RFC 2049 ) defines extensions that allow you to specify various types of email content.
One very useful thing that you can use with MIME is to specify a Content-Type (e.g. text/html or application/octet-stream ).
Another useful thing is that you can create a message from several parts (for example, if you want the HTML and the image to be inside the HTML). This is done by specifying multipart content ( RFC 2046, section 5.1 ).
Compound Messages
If the message has a multipart type of content, then this means that it consists of several messages, and each of them defines its own type of content (which again can be composite or something else). Compound messages in Python are represented by the MIMEMultipart class.
So, to answer question 3 : When MIMEMultipart used, then yes, it is a tree structure, but if only MIMEText , then it is not a tree.
Question 4 asks which class to set the headers for (To, From, etc.) - this is done for the Message class, but all MIME classes MIME inherited from Message , so this can be done for any of them, except for those which headers make sense only at the root of the compound message.
In other words, if the message consists of only one MIME part, specify the headers for this part. If it consists of several parts, then the root is MIMEMultipart - specify the headers for this part.
Question 2 asks "when to use MIMEMultipart, MIMEText and MIMEBase." - MIMEBase is just a base class. As stated in the specification : "Usually you will not create instances specifically for MIMEBase " - MIMEText intended for text (for example, text/plain or text/html ) if the entire message is in text format or part of it. - MIMEMultipart in order to say "I have more than one part" and then list the parts - you do this if you have attachments, you also do this to provide alternative versions of the same content (for example, text version plus version HTML)
Question 5 "What is a payload?" is just a buzzword for the content of the message (or part of the message)
Question 6 There is a restriction on the use of only 7 bits in SMTP. See this answer for more details.
I did not quite understand Question 1 , but it seems that the schedule is more or less correct. By the way, I would not use MIMEBase here, because there is MIMEApplication which seems more suitable for the intended purpose.