# coding:utf-8
from email.header import Header
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import smtplib
def mail_163(from_addr,to_addr):
password = '******' #第三方授权码
smtp_server = 'smtp.163.com'
msg = mail_content(from_addr,to_addr)
server = smtplib.SMTP_SSL(smtp_server,465)
server.set_debuglevel(1)
server.login(from_addr,password)
server.sendmail(from_addr,to_addr,msg.as_string())
server.quit()
def mail_content(from_addr,to_addr):
msg = MIMEText('关于周末一起吃鸡','plain','utf-8') #文本文档
#msg['From'] = Header('邢<%s>'% from_addr,'utf-8')
msg['From'] = from_addr
#msg['To'] =Header('周<%s>'% to_addr,'utf-8')
msg['To'] = to_addr
msg['Subject'] = Header('周末相约一起吃鸡','utf-8')
return msg
if __name__ == '__main__':
from_addr = '***@163.com'
to_addr = input('To:') ##或者直接定义一个to_addr的list
mail_163(from_addr,to_addr)