1 # Import smtplib for the actual sending function
4 # Here are the email pacakge modules we'll need
5 from email
.MIMEImage
import MIMEImage
6 from email
.MIMEMultipart
import MIMEMultipart
10 # Create the container (outer) email message.
12 msg
['Subject'] = 'Our family reunion'
13 # me == the sender's email address
14 # family = the list of all recipients' email addresses
16 msg
['To'] = COMMASPACE
.join(family
)
17 msg
.preamble
= 'Our family reunion'
18 # Guarantees the message ends in a newline
21 # Assume we know that the image files are all in PNG format
23 # Open the files in binary mode. Let the MIMEImage class automatically
24 # guess the specific image type.
26 img
= MIMEImage(fp
.read())
30 # Send the email via our own SMTP server.
33 s
.sendmail(me
, family
, msg
.as_string())