attached python mail Send script (for cases where sending a test message is unsuccessful, you can see Debug in the error code hint, such as ( 554, DT:SPM in general, messages sent are treated as spam and virus messages and need to be adjusted for the contents of the sender) :
#!/usr/bin/python # -*- coding: utf-8 -*-#python-version:2.7from email import encodersfrom email.header import headerfrom email.mime.text import Mimetextfrom email.utils import parseaddr, formataddrimport smtplibimport sysdef send_mail (_to_email,_subject,_message): from_addr = "[email Protected] " password = " Your_password " smtp_server = "smtp.163.com" msg = mimetext (_message, ' plain ', ' Utf-8 ') msg[' Subject '] = _subject server = Smtplib. SMTP (smtp_server, 25) # encrypted transport with SSL #server = Smtplib. Smtp_ssl (smtp_host,994) # turn on debug mode on the Send process server.set_ DebugLevel (1) server.login (From_addr, password) server.sendmail (FROM_ADDR, [_to_email], msg.as_string ()) server.quit () if __name__== ' __main__ ': send_mail (Sys.argv[1],sys.argv[2],sys.argv[3])
This article is from the "Trying" blog, make sure to keep this source http://tryingstuff.blog.51cto.com/4603492/1923962
Zabbix-python Send mail Script