首页 > 代码库 > python发送QQ邮箱方法
python发送QQ邮箱方法
1 import smtplib 2 from email.mime.text import MIMEText 3 4 mail_user = "user1@qq.com" 5 mail_pwd = "password" 6 mailto_list=["user2@qq.com", "user3@qq.com"] 7 8 def send_mail(from_address, to_address_list, mail_subject, mail_content): 9 msg = MIMEText(mail_content) 10 msg["Subject"] = mail_subject 11 msg[‘From‘] = from_address 12 msg[‘To‘] = ";".join(to_address_list) 13 14 s = smtplib.SMTP("smtp.qq.com", timeout=30)#连接smtp邮件服务器,端口默认是25 15 #s = smtplib.SMTP_SSL("smtp.qq.com", 465) #连接方法一 16 #s = smtplib.SMTP() #连接方法二 17 #s.connect(mail_host) 18 s.login(from_address, mail_pwd) 19 s.sendmail(from_address, to_address_list, msg.as_string()) 20 #s.quit() 21 s.close() 22 23 send_mail(mail_user, mailto_list, ‘群发主题‘, ‘群发内容‘)
python发送QQ邮箱方法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。