Python email: Sina Normal Edition | Zabbix version

Source: Internet
Author: User

from email.mime.text import mimetextfrom email.header import headerfrom  Smtplib import smtp_ssldef send_mail (sender_sina= ", pwd=", receiver= ", mail_title=", Mail_ Content= '):    #  mailbox SMTP Server     host_server =  ' Smtp.sina.com '     sender_sina_mail = sender_sina+ ' @sina. com '       #ssl登录     smtp = smtp_ssl (host_server)      #set_ DebugLevel () is used for debugging. A parameter value of 1 means turn on debug mode with a parameter value of 0 to turn off debug mode     smtp.set_debuglevel (0)     smtp.ehlo (host_ Server)     smtp.login (sender_sina, pwd)     msg =  Mimetext (mail_content,  "plain",  ' utf-8 ')     msg["Subject"] = header ( mail_title,  ' utf-8 ')     msg["from"] = sender_sina_mail     msg["to"] = Receiver    smtp.sendmail (Sender_sina_mail, receiver, msg.as_string ())      smtp.quit () send_mail ("hequan2011", "Password", "[email protected]", "title", ' content ')


#!/usr/bin/python#coding:utf-8from email.mime.text import mimetextfrom email.header  Import headerfrom smtplib import smtp_sslimport sysdef send_mail (sender_sina= ", Pwd= ', receiver= ', mail_title= ', mail_content= '):    host_server =  ' Smtp.sina.com '     sender_sina_mail = sender_sina+ ' @sina. com '       #ssl登录     smtp = smtp_ssl (host_server)      #set_ DebugLevel () is used for debugging. A parameter value of 1 means turn on debug mode with a parameter value of 0 to turn off debug mode     smtp.set_debuglevel (0)     smtp.ehlo (host_ Server)     smtp.login (sender_sina, pwd)     try:         msg = mimetext (mail_content,  "plain",  ' utf-8 ')          msg["Subject"] = header (mail_title,  ' utf-8 ')           msg["from"] = sender_sina_mail        msg ["To"] = receiver        smtp.sendmail (Sender_sina_mail,  receiver, msg.as_string ())         smtp.quit ()          print ("Send Success")         return   True    except  Exception as e :         print ("Send failed:", e)         return false         if __name__== "__main__":     #send_ Mail ("hequan2011", "Password", "[email protected]", "title", "Content")     send_mail ("hequan2011",   "Password",  sys.argv[1], sys.argv[2], sys.argv[3])


This article is from the "what-all" blog, please be sure to keep this source http://hequan.blog.51cto.com/5701886/1939844

Python email: Sina Normal Edition | Zabbix version

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.