python - 当我使用 jinja 模板发送电子邮件时,css 不起作用
问题描述
我正在尝试使用 jinja 模板发送电子邮件,但样式(css)不起作用
这是我用来发送带有模板的电子邮件的代码
msg = EmailMessage()
msg['Subject'] = 'Prueba de correo'
msg['From'] = 'my address email'
msg['To'] = 'name@domail.com'
msg.set_content('Correo automatico desde python')
html = render_template('email.html');
msg.add_alternative(html,subtype="html")
with smtplib.SMTP_SSL('smtp.gmail.com',465) as server:
server.login('my address email ','my password')
server.send_message(msg)
server.quit()
这是神社模板
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!-- <link rel="stylesheet" href="{{ url_for('static', filename='email.css') }}"/> -->
</head>
<body>
<style>
h1{
text-align: center;
color: red;
}
</style>
<h1>Hola Mundo</h1>
</body>
</html>
但是当电子邮件发送时
看起来像这样
它应该是这样的
解决方案
您是否尝试过取消注释标签?
该行应为:
<link rel="stylesheet" href="{{ url_for('static', filename='email.css') }}"/>
推荐阅读
- flex-lexer - 如何为同一文本调用多个词法分析器?
- android - 是否可以更改 apk 的签名?
- typescript - TypeScript如何为空数组定义元组类型?
- c# - 将图像上传到 azure blob 存储 - 在本地工作,部署时失败
- google-sheets - Google 表格中的日期格式 SQL 查询
- visual-studio-code - 在 React JavaScript 文件中禁用 VS Code Stylelint 错误
- arrays - Ruby - 如何删除哈希数组中的重复项?
- java - 如何从 android 的 sdcard 中存储的图像生成 mp4 格式的视频文件?
- c# - 可查询的
没有获得导航属性 - java - java.lang.OutOfMemoryError: Java heap space Error while running hive table scan