HTML 电子邮件未显示在 Mailcatcher 中,但文本显示
HTML email does not show up in Mailcatcher, but text does
我在哪里可以找到可以帮助我找出问题原因的日志?我有一个 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()
搞清楚了,这是 MailCatcher 的一个已知错误。 0.5.12
之后的版本在发送 utf8
html 电子邮件时崩溃。当前版本是 0.6.4
- 2/4/16(仍然有问题)。
降级到 0.5.12
解决了问题。
我在哪里可以找到可以帮助我找出问题原因的日志?我有一个 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()
搞清楚了,这是 MailCatcher 的一个已知错误。 0.5.12
之后的版本在发送 utf8
html 电子邮件时崩溃。当前版本是 0.6.4
- 2/4/16(仍然有问题)。
降级到 0.5.12
解决了问题。