import smtplib
from email.MIMEText import MIMEText
fromaddr = 'xxx1@gmail.com'
toaddrs = ['xx@sina.com','aaaa@gmail.com']
msg = MIMEText("test content", "plain")
msg['Subject']= "test subject" # 邮件主题要这么加,真麻烦
username = 'gmail_user_name'
password = 'gmail_user_password'
server = smtplib.SMTP('smtp.gmail.com')
server.ehlo()
server.starttls()
server.ehlo()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, msg.as_string())
server.quit()
给gmai邮箱发邮件的一段python小脚本
最新推荐文章于 2021-06-17 19:04:20 发布