python脚本验证brevo stmp tls加密邮件发送

smtp供应商

每天免费发送300份邮件,每月免费发送9000份邮件

脚本

key_xxx为SMTP key value

import smtplib

# SMTP服务器设置
smtp_server = 'smtp-relay.brevo.com'
smtp_port = 587
smtp_user = 'sobergou@gmail.com'
smtp_password = 'key_xxx'

# 邮件内容
from_addr = 'xahm@zeppos.tech'
to_addr = 'sobergou@gmail.com'
subject = 'SMTP Test Email'
body = 'This is a test email sent via SMTP.'

# 创建SMTP连接
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()  # 启用TLS加密
server.login(smtp_user, smtp_password)

# 发送邮件
msg = f"From: {from_addr}\r\nTo: {to_addr}\r\nSubject: {subject}\r\n\r\n{body}"
server.sendmail(from_addr, to_addr, msg)
server.quit()

print("Test email sent successfully!")

接收的邮件

image