Advertisement
viki_omega9

SMTP Code

May 16th, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import smtplib
  2. from email.mime.text import MIMEText
  3.  
  4. print "Sending Email ..."
  5.  
  6. print "\tSet-up"
  7.  
  8. fromaddr = ""
  9. toaddr = []
  10. toaddr.append("skjfbg")
  11. #toaddr.append("")
  12. #toaddr.append("")
  13. sub = "Lorem Ipsum"
  14. to = ""
  15.  
  16. username = ''
  17. password = ''
  18.  
  19. msg = MIMEText("Hi There")
  20. msg['Subject'] = "hi"
  21. msg['From'] = fromaddr
  22. msg['To'] = toaddr
  23.  
  24. try:
  25.     server = smtplib.SMTP('smtp.gmail.com:587')
  26.     server.starttls()
  27.     server.login(username, password)
  28.  
  29.     #for i in toaddr:
  30.     print "\tSending"
  31.     server.sendmail(fromaddr, to, str(msg))
  32.  
  33.     server.quit()
  34. except:
  35.     print "Failed To Send Email"
  36.     raise
  37.  
  38. else:
  39.     print "\tDone\nDone Sending Email ..."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement