我正在尝试通过HTML电子邮件发送邮件。一切都运行得很好,但html文件的内联css并没有在实际的电子邮件中呈现出来。 视图.py
subject = 'Activate Your Account.'
htmly = get_template('account_activation_email.html')
d = { 'user': user, 'domain':current_site.domain, 'uid':urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user)}
text_content = ""
html_content = htmly.render(d)
msg = EmailMultiAlternatives(subject, text_content, '', [user.email])
msg.attach_alternative(html_content, "text/html")
try:
msg.send()
except BadHeaderError:
print("Error while sending email!")
这里是我的html文件:
<html>
<head>
</head>
<body>
<div style="backgound-color:red;position:relative;width:100%;text-align:center;">Email Verification</div>
Hi {{ user.username }},
</body>
请帮帮我!你知道吗
红色背景被跳过,因为拼写:
backgound-color
vsbackground-color
。你知道吗你也尝试过不同的电子邮件客户端-HTML电子邮件是非常它自己的艺术。你知道吗
相关问题 更多 >
编程相关推荐