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()