Advertisement
Guest User

Untitled

a guest
Jan 5th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import smtplib
  2. from email.mime.multipart import MIMEMultipart
  3. from email.mime.text import MIMEText
  4.  
  5. me = "tonyr1291@gmail.com"
  6. you = "testaccount@gmail.com"
  7.  
  8.  
  9. msg = MIMEMultipart('alternative')
  10. msg['Subject'] = "Link"
  11. msg['From'] = me
  12. msg['To'] = you
  13.  
  14. text = "Hi!nHow are you?nHere is the link you wanted:nhttp://www.python.org"
  15. html = """
  16. <html>
  17. <head></head>
  18. <body>
  19. <p>Hi!<br>
  20. How are you?<br>
  21. Here is the <a href="http://www.python.org">link</a> you wanted.
  22. </p>
  23. </body>
  24. </html>
  25. """
  26.  
  27. part1 = MIMEText(text, 'plain')
  28. part2 = MIMEText(html, 'html')
  29.  
  30. msg.attach(part1)
  31. msg.attach(part2)
  32.  
  33. s = smtplib.SMTP('localhost',5000)
  34. s.sendmail(me, you, msg.as_string())
  35. s.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement