Advertisement
Guest User

Untitled

a guest
Nov 29th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. # -*- coding: UTF-8 -*-
  2. import smtplib
  3. from email.MIMEText import MIMEText
  4.  
  5. mailto_list = ['xenuhuhol@polyfaust.com', ]
  6. mail_host = "smtp.test.net"
  7. mail_user = "test-mail"
  8. mail_pass = "124qwrasf"
  9. mail_postfix = "8864.com"
  10. mail_file = open('e:\\TRACH\\1.txt', 'rb')
  11. mail_message = mail_file.read()
  12.  
  13.  
  14. def send_mail(to_list, sub, content):
  15. me = "phpchecker" + "<" + mail_user + "@" + mail_postfix + ">"
  16. msg = MIMEText(content, _subtype='plain', _charset='gb2312')
  17. msg['Subject'] = sub
  18. msg['From'] = me
  19. msg['To'] = ";".join(to_list)
  20. try:
  21. server = smtplib.SMTP()
  22. server.connect(mail_host, port=587)
  23. server.login(mail_user, mail_pass)
  24. server.sendmail(me, to_list, msg.as_string())
  25. server.close()
  26. return True
  27. except Exception, e:
  28. print str(e)
  29. return False
  30.  
  31.  
  32. send_mail(mailto_list, "Python_Check_Warning", mail_message)
  33. if __name__ == '__main__':
  34. if send_mail(mailto_list, "PHP_Check_Warning", mail_message):
  35. print "Success"
  36. else:
  37. print "Error"
  38. mail_file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement