#coding:utf-8
from email.header import Header
from email.mime.text import MIMEText
import smtplib
#发件人地址
from_addr = 'xxxxxx@163.com'
#发件人密码
password ='xxxxxxx'
#收件人地址
to_addr = 'xxxxx@xxx.com'
#163邮箱服务器地址
smtp_server = 'smtp.163.com'
#设置邮箱信息
msg = MIMEText('python send email is very good','plain','utf-8')
msg['From'] ='Zhang<%s>'% from_addr
msg['To'] = to_addr
msg['Subject'] = Header('请查看','utf-8')
#send
server =smtplib.SMTP(smtp_server,25)
server.login(from_addr,password)
server.sendmail(from_addr,to_addr,msg.as_string())
server.quit()
结果:
结果:
欢迎进(Q)群,帮你解决问题: