# Import smtplib for the actual sending function.1import smtplib23# Here are the email package modules we'll need.4from email.message import EmailMessage56# Create the container email message.7msg = EmailMessage()8msg['Subject'] = 'Our family reunion'9# me == the sender's email address10# family = the list of all recipients' email addresses11msg['From'] = me12msg['To'] = ', '.join(family)13msg.preamble = 'You will not see this in a MIME-aware mail reader.\n'1415# Open the files in binary mode. You can also omit the subtype16# if you want MIMEImage to guess it.17for file in pngfiles:18with open(file, 'rb') as fp:19img_data = fp.read()20msg.add_attachment(img_data, maintype='image',21subtype='png')2223# Send the email via our own SMTP server.24with smtplib.SMTP('localhost') as s:25s.send_message(msg)262728