Guest User

Untitled

a guest
Sep 22nd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import smtplib
  2. import email.utils
  3. from email.mime.text import MIMEText
  4.  
  5. # Prompt the user for connection info
  6. username = raw_input('Your Email:')
  7. password = raw_input("Your password:")
  8. to_email = raw_input('Recipient Email:')
  9. servername = "smtp.gmail.com:587"
  10.  
  11. # Create the message
  12. Subject1 = raw_input("Subject:")
  13. From1 = raw_input("Name of Sender as:")
  14. To1 = raw_input("Name of Recipient as:")
  15. msg = MIMEText(raw_input("Enter message body:"))
  16. msg.set_unixfrom("")
  17. msg['Subject'] = Subject1
  18. msg['From'] = email.utils.formataddr((From1, username))
  19. msg['To'] = email.utils.formataddr((To1, to_email))
  20.  
  21. server = smtplib.SMTP(servername)
  22. server.starttls()
  23. server.login(username, password)
  24. server.sendmail(username, to_email, str(msg))
  25. # Whats the difference between msg.as_string() and str(msg) ?
  26. #from asdpoias import asoidjasd , why not just import it all ?
  27. #Whats msg.set_unixfrom()?
  28. #and msg[]
Add Comment
Please, Sign In to add comment