# -*- coding:utf-8 -*-
import smtplib
from email.header import Header
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
# ----------1跟发件相关的参数------
smtpserver = "smtp.163.com" # 发件服务器
port = 0 # 端口
sender = "xxx@163.com" # 账号
psw = "xxx" # 密码
receiver = "xxx@qq.com" # 接收人
# ----------2编辑邮件的内容------
subject = "这个是主题 163"
body = '<p>这个是发送的 163 邮件</p>' # 定义邮件正文为 html 格式
msg = MIMEText(body, "html", "utf-8")
msg['from'] = sender
msg['to'] = "xxx@qq.com"
msg['subject'] = subject
# ----------3发送邮件------
smtp = smtplib.SMTP()
smtp.connect(smtpserver) # 连服务器
smtp.login(sender, psw) # 登录
smtp.sendmail(sender, receiver, msg.as_string()) # 发送
smtp.quit() # 关闭