import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
mail_host="xxx" #设置服务器(需要设置邮件服务器允许)
mail_user="xxx"#用户名
mail_pass="xxx"#密码
sender='xxx'#发送方用户名
receivers='xxx'#接收人
message=MIMEMultipart()
body='biu biu biu'#邮件内容
body=MIMEText(body)
message.attach(body)
message['From']=mail_user
message['To']=receivers
message['Subject']=('漂亮的人')#标题
smtpObj = smtplib.SMTP_SSL(mail_host)
smtpObj.login(mail_user,mail_pass)
smtpObj.sendmail(mail_user, receivers, message.as_string())
smtpObj.quit()
print ("邮件发送成功")