Django HTML电子邮件不会显示在Mailcatcher中,但文本会显示
我在哪里可以找到可能有助于我找到原因的日志?我有一个Django应用程序,配置为向运行Mailcatcher的服务器发送非生产环境电子邮件。当我发送纯文本电子邮件时,它会显示在Mailcatcher中,而当我添加其他HTML内容时,它们不会显示 我使用的是Django HTML电子邮件不会显示在Mailcatcher中,但文本会显示,django,email,mailcatcher,Django,Email,Mailcatcher,我在哪里可以找到可能有助于我找到原因的日志?我有一个Django应用程序,配置为向运行Mailcatcher的服务器发送非生产环境电子邮件。当我发送纯文本电子邮件时,它会显示在Mailcatcher中,而当我添加其他HTML内容时,它们不会显示 我使用的是EmailMultiAlternatives,为了测试这一点,我用attach_alternative()注释了我的行,只发送文本,效果很好。runserver没有错误,email.send()返回1 失败: @staticmethod def
EmailMultiAlternatives
,为了测试这一点,我用attach_alternative()
注释了我的行,只发送文本,效果很好。runserver没有错误,email.send()
返回1
失败:
@staticmethod
def send_payment_confirmation(client, free_trial_days, recur_id):
context = {
'recur_id': recur_id,
'client': client,
'free_trial_days': free_trial_days
}
html_body = render_to_string('email/html/payment_confirmation.html', context)
text_body = render_to_string('email/text/payment_confirmation.txt', context)
email = EmailMultiAlternatives(subject=u"Thank You For Your Payment,{}".format(client.name),
body=text_body, to=[client.get_contact_email()], bcc=['support@example.com'])
email.attach_alternative(html_body, "text/html")
email.send()
作品:
@staticmethod
def send_payment_confirmation(client, free_trial_days, recur_id):
context = {
'recur_id': recur_id,
'client': client,
'free_trial_days': free_trial_days
}
html_body = render_to_string('email/html/payment_confirmation.html', context)
text_body = render_to_string('email/text/payment_confirmation.txt', context)
email = EmailMultiAlternatives(subject=u"Thank You For Your Payment,{}".format(client.name),
body=text_body, to=[client.get_contact_email()], bcc=['support@example.com'])
# email.attach_alternative(html_body, "text/html")
email.send()
弄明白了,这是MailCatcher的一个已知错误。
0.5.12之后的版本在发送utf8
html电子邮件时崩溃。当前版本是0.6.4
-2/4/16(仍然存在此问题)
降级到0.5.12
可解决此问题
您确定名称拼写正确吗?在你的问题中,他们都错了(EmailMultiAltenitives
和attach_Altenitive()
)对不起,输入错误。它们在我的代码中拼写正确。