Staging
v0.8.1
Revision 72227035fe52ae825dac8760d8505dde64f041bf authored by Benjamin Peterson on 28 May 2009, 03:32:08 UTC, committed by Benjamin Peterson on 28 May 2009, 03:32:08 UTC
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r72977 | benjamin.peterson | 2009-05-27 22:30:13 -0500 (Wed, 27 May 2009) | 9 lines

  Merged revisions 72971 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r72971 | benjamin.peterson | 2009-05-27 22:02:13 -0500 (Wed, 27 May 2009) | 1 line

    switch library reference and language reference
  ........
................
1 parent dc020b1
Raw File
email-simple.py
# Import smtplib for the actual sending function
import smtplib

# Import the email modules we'll need
from email.mime.text import MIMEText

# Open a plain text file for reading.  For this example, assume that
# the text file contains only ASCII characters.
fp = open(textfile, 'rb')
# Create a text/plain message
msg = MIMEText(fp.read())
fp.close()

# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'The contents of %s' % textfile
msg['From'] = me
msg['To'] = you

# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP()
s.connect()
s.sendmail(me, [you], msg.as_string())
s.close()
back to top