标签:password import 测试 tar rom art 返回 username 进阶
一、python邮件发送
import smtplib # 发送邮件模块 from email.mime.text import MIMEText # 定义邮件内容 from email.header import Header # 定义邮件标题 # 发送邮箱服务器 smtpserver = "smtp.163.com" # 发送邮箱用户名密码 username = "n18604459833@163.com" password = "LIna2014" # 发送和接收邮箱 sender = "n18604459833@163.com" receive = "li17802929732@126.com" #发送邮件主题和内容 subject = "Web Selenium 自动化测试报告" content = ‘<html><h1 style="color:red">我要自学网,自学成才</h1></html>‘ #HTML邮件正文 msg = MIMEText(content, ‘html‘, ‘utf-8‘) msg[‘Subject‘] = Header(subject, ‘utf-8‘) msg[‘From‘] = ‘n18604459833@163.com‘ msg[‘To‘] = ‘li17802929732@126.com‘ #SSL协议端口使用465 smtp = smtplib.SMTP_SSL(smtpserver, 465) #向服务器标适识用户身份 smtp.helo(smtpserver) #服务器返回结果确认 smtp.ehlo(smtpserver) #登录邮箱服务器用户名和密码 smtp.login(username, password) print("Start send Email...") smtp.sendmail(sender, receive, msg.as_string()) smtp.quit() print("Send Email end")
标签:password import 测试 tar rom art 返回 username 进阶
原文地址:https://www.cnblogs.com/xidian2014/p/10425002.html