Python3 入门专栏
http://blog.youkuaiyun.com/column/details/19679.html
Python 发送 SMTP 邮件
python 的 smtplib 模块对 smtp 协议进行了简单的封装,可以用于发送 smtp 协议的电子邮件;
发送普通邮件
import smtplib
from email.header import Header
from email.mime.text import MIMEText
# 使用 163 邮箱的 SMTP 服务
mail_host = "smtp.163.com" # smtp 服务器
mail_user = "helloworld_assad@163.com" # smtp 服务器验证用户名
mail_password = "*************" # smtp 服务器验证密码(smtp 授权码)
sender = "helloworld_assad@163.com" # 发送地址
receivers = ["yulinying_1994@outlook.com"] # 接收地址
# 信息对象(dict 对象)
message = MIMEText("Hello world", "plain", "utf-8")
message["From"] = Header("assad", "utf-8")
message["To"] = Header("Mr.lin", "utf-8")
message["Subject"] = Header("python smtp 邮件测试", "utf-8")

最低0.47元/天 解锁文章
557

被折叠的 条评论
为什么被折叠?



