More installation info. Bump alpha version.
[python/dscho.git] / Doc / lib / email-mime.py
blob28c8d2ed83e466dc27cc13e13192271f4d69b13a
1 # Import smtplib for the actual sending function
2 import smtplib
4 # Here are the email pacakge modules we'll need
5 from email.MIMEImage import MIMEImage
6 from email.MIMEMultipart import MIMEMultipart
8 COMMASPACE = ', '
10 # Create the container (outer) email message.
11 msg = MIMEMultipart()
12 msg['Subject'] = 'Our family reunion'
13 # me == the sender's email address
14 # family = the list of all recipients' email addresses
15 msg['From'] = me
16 msg['To'] = COMMASPACE.join(family)
17 msg.preamble = 'Our family reunion'
18 # Guarantees the message ends in a newline
19 msg.epilogue = ''
21 # Assume we know that the image files are all in PNG format
22 for 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)
30 # Send the email via our own SMTP server.
31 s = smtplib.SMTP()
32 s.connect()
33 s.sendmail(me, family, msg.as_string())
34 s.close()