首页 > 其他 > 详细

发送邮件

时间:2021-08-07 14:58:11      阅读:20      评论:0      收藏:0      [点我收藏+]

import smtplib
from email.mime.text import MIMEText

def send_mail(receiver_address, content):
    """发送邮件通知"""
    # 连接邮箱服务器信息
    host = ‘smtp.163.com‘
    port = 25
    sender = ‘wztshine@163.com‘  # 发件邮箱
    pwd = ‘xxxxx‘  # 不是登陆密码,是客户端授权密码
    # 发件信息
    body = ‘<h2>温馨提醒:</h2><p>‘ + " "+content + ‘</p>‘
    msg = MIMEText(body, ‘html‘, _charset="utf-8")
    msg[‘subject‘] = ‘你好!‘  # 邮件主题
    msg[‘from‘] = sender
    msg[‘to‘] = receiver_address
    s = smtplib.SMTP(host, port)
    # 开始登陆邮箱,并发送邮件
    s.login(sender, pwd)
    s.sendmail(sender, receiver_address, msg.as_string())
    s.quit()
    
send_mail(‘241949382@qq.com‘,"hahaha")

发送邮件

原文:https://www.cnblogs.com/wztshine/p/15111106.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!