首页 > 其他 > 详细

脚本邮箱监控

时间:2019-08-24 18:53:27      阅读:72      评论:0      收藏:0      [点我收藏+]
# coding=utf-8
"""
发送邮件
"""
import smtplib
from email.mime.text import MIMEText
from email.header import Header


def send_mail(content=""):
print("send_mail")
smtphost = ‘smtp.exmail.qq.com‘ # smtp服务器
port = 465 # smtp服务器端口
sender = "xxxx@xx.com" # 发件人邮箱
pwd = "xxxxx" # 邮箱密码
receivers = [‘xxx@xx.cn‘, ‘xxx@xxxcn‘, ‘xxxxx@qq.com‘] # 收件人邮箱
subject = "幸运开学季脚本" # 主题
content = content or "***"
msg = MIMEText(content, ‘plain‘, ‘utf-8‘) # 参数分别是邮件内容、文本格式、编码
msg[‘from‘] = Header(sender) # 谁发
msg[‘to‘] = Header("lucky_2019") # 发给谁
msg[‘subject‘] = Header(subject) # 邮件主题
try:
smtpObj = smtplib.SMTP_SSL(smtphost, port) # SSL加密
smtpObj.login(sender, pwd)
smtpObj.sendmail(sender, receivers, msg.as_string())
print("send mail successfully")
except smtplib.SMTPException as e:
print(e)
return 1


def run():
print(‘开始执行‘)
while True:
try:
data_list = award_list()
action_award(data_list)
except Exception as e:
print(e)
msg = f"2019开学季-教师或学生脚本处理报错, 循环退出了 error is {e}"
print(msg)
mail(msg)
continue


if __name__ == "__main__":

run()




脚本邮箱监控

原文:https://www.cnblogs.com/laowang-106/p/11405490.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!