标签:xxx 默认 企业邮 bsp ssl rom war except info
#/usr/bin/env python
#-*- coding:utf-8 -*-
from email.mime.text import MIMEText
from email.header import Header
import smtplib
message =‘‘‘
故障故障,快检查下。。
‘‘‘
msg = MIMEText(message,‘plain‘,‘utf-8‘)
msg[‘Subject‘] = Header("来之服务器的报警",‘utf-8‘)
msg[‘From‘] = Header(‘warning@xxx.net‘)
msg[‘To‘] = Header(‘receiver‘,‘utf-8‘)
from_addr = ‘fuchang.chen@ssssss‘ #发件邮箱
password = ‘xxxxxxxx‘ #邮箱密码(或者客户端授权码)
to_addr = ‘yinghao.li@westwell-lab.com‘ #收件邮箱
smtp_server = ‘smtp.exmail.qq.com‘ #企业邮箱地址,若是个人邮箱地址为:smtp.163.com
try:
server = smtplib.SMTP_SSL(smtp_server,465) #第二个参数为默认端口为25,这里使用ssl,端口为994
print(‘开始登录‘)
server.login(from_addr,password) #登录邮箱
print(‘登录成功‘)
print("邮件开始发送")
server.sendmail(from_addr,to_addr,msg.as_string()) #将msg转化成string发出
server.quit()
print("邮件发送成功")
except smtplib.SMTPException as e:
print("邮件发送失败",e)
标签:xxx 默认 企业邮 bsp ssl rom war except info
原文地址:https://www.cnblogs.com/cfc-blog/p/10815074.html