Python模拟QQ群发邮件

#coding=utf-8

import smtplib
import time
from email.mime.text import MIMEText

server = "smtp.qq.com"

send_username = "123456789@qq.com"#自己的账号
send_password = "olxhqoimmcazejhd"#刚才发的授权码
send_title = "病毒病毒"#邮件标题
send_msg = "来自叶大哥的重磅警告"#邮件内容
send_name = "阿里首席执行官"#发件人姓名

msg = MIMEText(send_msg)
msg["subject"] = send_title
msg["From"] = send_name

email = smtplib.SMTP(server,25)#数字是死的
email.login(send_username,send_password)
file = open("QQ.txt")
for line in file:
    #延时20s 这里是为了防止被腾讯封号
    time.sleep(20)
    #拼接字符串
    str_name1 = line
    str_name2 = "@qq.com"
    str_name = str_name1 + str_name2
    to_username = str_name
    print(to_username)
    #发送邮件
    email.sendmail(send_username,to_username,msg.as_string())

#退出邮箱
email.quit()

posted @ 2023-04-23 19:42  Lauriee  阅读(18)  评论(0编辑  收藏  举报  来源