【问题标题】:django-allauth: email confirmationdjango-allauth:电子邮件确认
【发布时间】:2016-07-02 14:13:00
【问题描述】:

我已经设置了 django-allauth 并在新用户注册时使用电子邮件确认,效果很好

但是在确认邮件中,我得到了

Hello from example.com!

    You're receiving this e-mail because user abc13 at example.com has given yours as an e-mail address to connect their account.

    To confirm this is correct, go to http://<mysite>.com/accounts/confirm-email/q3rknxpflshgwddlbjw6aqzlr1ayqtnfrtezucoq2ysmfbm2etcldusq5dyrcoap/

    Thank you from example.com!
    example.com

如何将“example.com”替换为我的网站名称?

谢谢

【问题讨论】:

    标签: python django django-allauth


    【解决方案1】:

    听起来您需要更新 Django 管理员中的 Site 条目。您可以通过以下方式访问:

    http://<yoursite>.com/admin/sites/site/
    

    【讨论】:

    • 并且不要忘记在 settings.py 上添加 SITE_ID 并将 django.contrib.sites 添加到 installed_apps ,否则我们会收到错误提示。这是一个非常好的错误消息,因为它直接告诉我们需要将 django.contrib.sites 添加到 installed_apps。
    【解决方案2】:

    您还可以使用以下内容创建完全自定义的电子邮件:

    @receiver(user_signed_up)
    def user_signed_up_(sender,request,user,**kwargs):
    
        subject, from_email, to = 'Welcome', 'admin@mysite', 'person@somewhere'
        text_content ="some custom text or html"
        msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
        msg.attach_alternative(html_content, "text/html")
        msg.send()
    

    【讨论】:

    • 这个函数去哪儿了?
    • 如果你这样做,你需要在 settings.py 下禁用默认电子邮件
    猜你喜欢
    • 1970-01-01
    • 2017-05-12
    • 2014-07-30
    • 2016-07-01
    • 2015-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多