【问题标题】:django-allauth HTML email not senddjango-allauth HTML 电子邮件未发送
【发布时间】:2013-06-27 07:30:08
【问题描述】:

我在我的模板文件夹中添加了以下子文件夹和文件以覆盖电子邮件(遵循文档https://github.com/pennersr/django-allauth#sending-e-mail)a

templates/
   account/
     email/
       email_confirmation_message.html
       email_confirmation_message.txt
       email_confirmation_subject.txt

覆盖非常适合 *.txt 版本的电子邮件(意思是,我认为,我有一个正确的文件夹结构)但我的问题是 HTML 版本不是由 django_allauth 发送的。

【问题讨论】:

  • 您使用的是什么版本(HTML 邮件是 0.10+)?否则,我建议您单步执行以下代码:github.com/pennersr/django-allauth/blob/… 以查看为什么没有被拾取——您的目录结构看起来不错。
  • 我使用的是 0.11.1 版本。我已经阅读了源代码,但没有彻底阅读“那个”。我会读增益。谢谢
  • 好的,原来涉及的源代码实际上如下:github.com/pennersr/django-allauth/blob/… 如果我仔细阅读文档,并没有提到 django_allauth 对新注册用户有影响或者不是电子邮件注册消息。我会继续我的测试,我想我需要 6 个模板(email_confirmation_signup* 和 email_confirmation*)
  • 好吧,我想通了。现在清晰易懂。昨天真的很累,没注意。我不清楚的是,我的 email_confirmation_message.txt 覆盖版本是在我的测试期间发送的(而不是源版本 email_confirmation_signup_message.txt)

标签: django django-allauth


【解决方案1】:

对于那些面临同样问题的人:

当涉及到电子邮件确认时,django_allauth 检查它是否是新用户并相应地查找模板:

所以你必须重写:

email_confirmation_message.txt
email_confirmation_signup_message.txt

并添加 HTML 版本

email_confirmation_message.html
email_confirmation_signup_message.html

【讨论】:

  • 另外,我必须在文件email_confirmation_signup_message.html 中将文件扩展名更改为.html{% include "account/email/email_confirmation_message.html" %}
  • {{ 用户 }} 和 {{ 确认链接 }} 怎么样,如何将这些添加到自定义模板中?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-10
  • 2020-09-14
  • 2014-10-26
  • 1970-01-01
  • 2021-02-24
  • 1970-01-01
相关资源
最近更新 更多