python发送html邮件缺少CSS样式

Thomas_young2015 2017-07-26 09:05:08



代码:
def send_mail_test(subject, content):
# 句柄
# msg = MIMEMultipart('related')
msg = MIMEText(content, 'html', 'base64')
msg['From'] = Header(u'<%s>' % sender, 'utf-8')
msg['To'] = Header(';'.join(receivers), 'utf-8')
msg['Subject'] = Header(subject, 'utf-8')

# 发送邮件
smtp = smtplib.SMTP()
try:
smtp.connect(mail_host, 25) # 25为SMTP端口号,465或者994为SSL协议端口
smtp.login(mail_user, mail_password)
smtp.sendmail(sender, receivers, msg.as_string())
print "发送邮件成功"
except smtplib.SMTPException:
print "Error, 发送邮件失败"
traceback.print_exc()
finally:
smtp.quit()


if __name__ == "__main__":
subject = u'【请阅】测试报告'
# content = u'含测试报告邮件测试'
# attach = scan_dir(SJ_RESULT, 'html')
# send_mail(subject, content, attach=attach)
file_html = scan_dir(SJ_RESULT, 'html')
with open(file_html, 'rb') as fp:
content = fp.read()

send_mail_test(subject, content)
...全文
943 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Thomas_young2015 2017-07-26
  • 打赏
  • 举报
回复
不知道该怎么解决,求大神。
Thomas_young2015 2017-07-26
  • 打赏
  • 举报
回复
应该是python发送邮件时,无法解析js。 原本的情况:<a class="popup_link" onfocus="this.blur();" href="javascript:showTestDetail('div_ft1.4')"> error</a> 邮件发送后:<a class="popup_link" target="_blank"> error</a>

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧