我想为我的网站制作一些漂亮的电子邮件模板,但是我在精心制作代码和功能之间存在冲突。
我的问题是,我所有的电子邮件模板都格式化为标准模板:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"...>
</head>
<body>
Some stuff
</body>
</html>
这段文本在网页上显示正常,但是在试图将其作为格式化电子邮件发送时,实际上只发送了 Some stuff
部分,这意味着没有任何格式能够被正确传递。
我的当前电子邮件代码如下:
message = Message(
subject="Subject",
html= render_template(
'emails/confirmation_email.html',
confirmation_code=confirmation.confirmation_code
),
sender = ("sender", "sender@gmail.com")
)
我正在使用Jinja2模板和Flask-Mail扩展。
基本上,我真的希望在我的电子邮件中包含这些样式表,但我非常反对在样式标记中包含所有内容。