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, '群发主题', '群发内容')