from smtplib import SMTP
import smtplib
from email.header import Header
smtpserver='smtp.sina.com'
password='123456'
user='username@sina.com'
sender='username@sina.com'
receiver='receive@sina.com'
subject='python email test'
smtp=smtplib.SMTP()
smtp.connect(smtpserver)
smtp.login(user,password)
smtp.sendmail(sender,receiver,msg.as_string())
smtp.quit();
def send_mail(file_new):
f=open(file_new,'rb')
mail_body=f.read()
f.close()
smtp=smtplib.SMTP()
if __name__ =='__main__':
test_dir='D:\\testpro\\test_case'
test_report='D:\\testpro\\report'
discover=unittest.defaultTestLoader.discover(test_dir,pattern='test_*.py')
now=time.starttime("%Y-%m-%d_%H_%M_%S")
filename=open(filename,'wb')
python自动化发送邮件
最新推荐文章于 2025-10-27 09:04:37 发布
博客展示了使用Python实现邮件发送的代码。通过导入相关库,设置邮件服务器、用户信息、发件人、收件人等,建立连接、登录并发送邮件。还包含读取文件内容作为邮件正文的函数,以及测试用例发现和报告生成的部分代码。
3928

被折叠的 条评论
为什么被折叠?



