This commit was manufactured by cvs2svn to create tag 'r234c1'.
[python/dscho.git] / Doc / lib / email-simple.py
bloba445f1bd1dd371cd461c0ad2191a726e9eb562d5
1 # Import smtplib for the actual sending function
2 import smtplib
4 # Import the email modules we'll need
5 from email.MIMEText import MIMEText
7 # Open a plain text file for reading. For this example, assume that
8 # the text file contains only ASCII characters.
9 fp = open(textfile, 'rb')
10 # Create a text/plain message
11 msg = MIMEText(fp.read())
12 fp.close()
14 # me == the sender's email address
15 # you == the recipient's email address
16 msg['Subject'] = 'The contents of %s' % textfile
17 msg['From'] = me
18 msg['To'] = you
20 # Send the message via our own SMTP server, but don't include the
21 # envelope header.
22 s = smtplib.SMTP()
23 s.connect()
24 s.sendmail(me, [you], msg.as_string())
25 s.close()