source: vendor/python/2.5/Doc/lib/email-simple.py

Last change on this file was 3225, checked in by bird, 18 years ago

Python 2.5

File size: 674 bytes
Line 
1# Import smtplib for the actual sending function
2import smtplib
3
4# Import the email modules we'll need
5from email.mime.text import MIMEText
6
7# Open a plain text file for reading. For this example, assume that
8# the text file contains only ASCII characters.
9fp = open(textfile, 'rb')
10# Create a text/plain message
11msg = MIMEText(fp.read())
12fp.close()
13
14# me == the sender's email address
15# you == the recipient's email address
16msg['Subject'] = 'The contents of %s' % textfile
17msg['From'] = me
18msg['To'] = you
19
20# Send the message via our own SMTP server, but don't include the
21# envelope header.
22s = smtplib.SMTP()
23s.connect()
24s.sendmail(me, [you], msg.as_string())
25s.close()
Note: See TracBrowser for help on using the repository browser.