Zabbix-python Send mail Script

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.