python
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def send_email(sender, password, receiver, subject, message):
smtp_server = 'smtp.qq.com'
smtp_port = 587
msg = MIMEMultipart()
msg['From'] = sender
msg['To'] = receiver
msg['Subject'] = subject
msg.attach(MIMEText(message, 'plain'))
with smtplib.SMTP(smtp_server, smtp_port) as server:
server.starttls()
server.login(sender, password)
server.send_message(msg)
if __name__ == '__main__':
sender = '23432324324@qq.com'
password = 'weweeeeeeeeeee' # QQ 邮箱的授权码,而不是登录密码
receiver = '123456568@qq.com'
subject = '自动化测试报告'
message = '这是自动化测试的报告,请查收。'
send_email(sender, password, receiver, subject, message)
QQ邮箱授权码在管理账户里获取