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自动化发送邮件
最新推荐文章于 2024-06-18 16:46:00 发布