我在哪里可以找到可能帮助我找到原因的日志?我有一个Django应用程序,配置为将非生产环境电子邮件发送到运行Mailcatcher的服务器。当我发送仅文本电子邮件时,它会显示在Mailcatcher中,当我添加替代HTML内容时,它们不会。
我正在使用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()
答案 0 :(得分:0)
想出这个,它是MailCatcher的一个已知错误。 0.5.12
html电子邮件发送utf8
后崩溃的版本。当前版本为0.6.4
- 2/4/16(仍有问题)。
降级为0.5.12
可以解决问题。