You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
612 B

  1. # Import smtplib for the actual sending function
  2. import smtplib
  3. # Import the email modules we'll need
  4. from email.mime.text import MIMEText
  5. # Open a plain text file for reading. For this example, assume that
  6. # the text file contains only ASCII characters.
  7. fp = open(textfile, 'rb')
  8. # Create a text/plain message
  9. msg = MIMEText(fp.read())
  10. fp.close()
  11. # me == the sender's email address
  12. # you == the recipient's email address
  13. msg['Subject'] = 'The contents of %s' % textfile
  14. msg['From'] = me
  15. msg['To'] = you
  16. # Send the message via our own SMTP server.
  17. s = smtplib.SMTP('localhost')
  18. s.send_message(msg)
  19. s.quit()