Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / email-mime.txt
CommitLineData
920dae64
AT
1# Import smtplib for the actual sending function
2import smtplib
3
4# Here are the email pacakge modules we'll need
5from email.MIMEImage import MIMEImage
6from email.MIMEMultipart import MIMEMultipart
7
8COMMASPACE = ', '
9
10# Create the container (outer) email message.
11msg = MIMEMultipart()
12msg['Subject'] = 'Our family reunion'
13# me == the sender's email address
14# family = the list of all recipients' email addresses
15msg['From'] = me
16msg['To'] = COMMASPACE.join(family)
17msg.preamble = 'Our family reunion'
18# Guarantees the message ends in a newline
19msg.epilogue = ''
20
21# Assume we know that the image files are all in PNG format
22for file in pngfiles:
23 # Open the files in binary mode. Let the MIMEImage class automatically
24 # guess the specific image type.
25 fp = open(file, 'rb')
26 img = MIMEImage(fp.read())
27 fp.close()
28 msg.attach(img)
29
30# Send the email via our own SMTP server.
31s = smtplib.SMTP()
32s.connect()
33s.sendmail(me, family, msg.as_string())
34s.close()