一个基于Python的邮箱推送脚本
这是把之前的漏洞库推送到QQ邮箱上面具体可以看上一篇CNNVD爬取
需要有一个邮箱授权码不知道哪里获取可以百度就不多详细的描述了
成品:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText import os os.getcwd() msg_from = '2632565822@qq.com' passwd = '邮箱授权码'
to = [ '2537225658@qq.com']
msg = MIMEMultipart() conntent = "漏洞推送"
msg.attach(MIMEText(conntent, 'plain', 'utf-8')) my_file = os.path.isfile('./bugku.csv') if my_file == True: os.renames(r"bugku.csv", "bugku.xlsx") else: pass
add = MIMEText(open('bugku.xlsx', 'rb').read(), 'base64', 'utf-8') add["Content-Type"] = 'application/octet-stream' add["Content-Disposition"] = 'attachment; filename="bugku.xlsx"' msg.attach(add)
msg['Subject'] = "推送"
msg['From'] = msg_from
s = smtplib.SMTP_SSL("smtp.qq.com", 465)
s.login(msg_from, passwd)
s.sendmail(msg_from, to, msg.as_string()) print("邮件发送成功")
|