17 smtplib

17.1 项目简介

smtplib模块定义一个SMTP客户机会话对象,该对象可用于将邮件发送到任何具有SMTP或ESMTP侦听器守护程序的Internet计算机。有关SMTP和ESMTP操作的详细信息,请参阅RFC 821(简单邮件传输协议)和RFC 1869(SMTP服务扩展)。

17.2 项目地址

https://github.com/python/cpython/blob/3.8/Lib/smtplib.py

17.3 文档地址

https://docs.python.org/3/library/smtplib.html

17.4 最佳实践

import smtplib
from  email.mime.text import MIMEText

send_user = '840964310@qq.com'
send_user_password = 'uuwtbwzklbwjbbjh'
receive_user = 'a112121788@163.com'


email_msg = MIMEText('正文,纯文本')

email_msg['Subject'] = '主题'
email_msg['From'] = send_user
email_msg['To'] = receive_user


# 准备发送
s = smtplib.SMTP_SSL('smtp.qq.com',465)
s.login(send_user, send_user_password)

# 发送邮件
s.sendmail(send_user, receive_user, email_msg.as_string())


© pengpeng 本站总访问量修改时间: 2020-07-26

results matching ""

    No results matching ""