Guest User

Untitled

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