blob: 077568d563be89530ed1666cc40cda4929abd6fa [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001# 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
R. David Murray7dff9e02010-11-08 17:15:13 +000020# Send the message via our own SMTP server.
R David Murraybb754b52011-04-30 17:26:32 -040021s = smtplib.SMTP('localhost')
R David Murray74612982011-04-30 17:19:53 -040022s.send_message(msg)
Jeroen Ruigrok van der Werven939c1782009-04-26 20:25:45 +000023s.quit()