Sending e-mail attachments
In the previous section, we have seen how plain text messages can be sent by using the SMTP protocol. In this section, let us explore how to send attachments through e-mail messages. We can use our second example, in which we have sent an e-mail by using TLS, for this. While composing the e-mail message, in addition to adding a plain text message, include the additional attachment field.
In this example, we can use the MIMEImage type for the email.mime.image sub-module. A GIF type of image will be attached to the e-mail message. It is assumed that a GIF image can be found anywhere in the file system path. This file path is generally taken on the basis of the user input.
The following example shows how to send an attachment ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access