Python uses QQ mailbox to send messages

Send messages via QQ mailbox

import smtplib
from email.message import EmailMessage

# 邮件内容
email = EmailMessage()
email['from'] = '[email protected]'
email['to'] = '接收信息的邮箱'
email['subject'] = '简单的邮件发送示例'
email.set_content('这是邮件的内容')

# 连接SMTP服务器并发送
smtp_server = 'smtp.qq.com'
smtp_port = 25
smtp_username = '[email protected]'
smtp_password = '邮箱授权码'

server = smtplib.SMTP(smtp_server, smtp_port)
server.login(smtp_username, smtp_password)
server.send_message(email)
server.quit()

"""
SMTP验证方式
SMTP服务器通常需要用户名和密码进行验证,也支持其他验证方式:
- PLAIN:明文传输,不安全
- LOGIN:Base64编码的用户名和密码
- CRAM-MD5:Challenge-Response Authentication Mechanism,使用MD5 Hash
- DIGEST-MD5:摘要式验证
- NTLM:NT LAN Manager,微软专用
- OAuth:OAuth授权验证
"""

insert image description here

Guess you like

Origin blog.csdn.net/qq_44534541/article/details/131205803