【问题标题】:Password reset in Django on nginx server writes to log file instead of sending emailnginx 服务器上 Django 中的密码重置写入日志文件而不是发送电子邮件
【发布时间】:2018-05-14 17:03:04
【问题描述】:

我有一个 Django 应用程序在带有 uWSGI 和 nginx 的服务器上运行。

在我的local_settings.py 文件中,我有这个:

###############
# EMAIL SETUP #
###############
EMAIL_HOST = 'smtp.privateemail.com'
EMAIL_HOST_USER = 'support@mydomain.com'
EMAIL_HOST_PASSWORD = 'MY EMAIL PASSWORD'
EMAIL_PORT = 465
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True


########################
# OTHER EMAIL SETTINGS #
########################
ADMIN_EMAIL = "admin@mydomain.com"
SUPPORT_EMAIL = "support@mydomain.com"

当我用电子邮件填写/password_reset/ 模板并提交表单时,我输入的地址不会收到密码重置消息。 error.log 中没有记录任何内容。这是我在 uwsgi.log

中看到的内容
[pid: 3354|app: 0|req: 1489/2206] 73.49.35.42 () {44 vars in 948 bytes} [Mon May 14 16:59:06 2018] GET /login-register/ => generated 7480 bytes in 39 msecs (HTTP/1.1 200) 3 headers in 102 bytes (2 switches on core 0)
[pid: 3355|app: 0|req: 718/2207] 73.49.35.42 () {44 vars in 994 bytes} [Mon May 14 16:59:14 2018] GET /password_reset/ => generated 3669 bytes in 38 msecs (HTTP/1.1 200) 4 headers in 256 bytes (1 switches on core 0)
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Subject: Password reset on Default
From: webmaster@localhost
To: email.to.send.password.reset@gmail.com
Date: Mon, 14 May 2018 16:59:16 -0000
Message-ID: <20180514165916.3354.5092@my-ubuntu-server-hostname.mydomain.com>



Hello,

You received this email because a request was made to reset the password.


If you requested this, go to the following page and choose a new password: https://127.0.0.1:8000/reset/MQ/4w6-efc1272e976075dfd881/

Your username: MyUsername

Thank you.



-------------------------------------------------------------------------------
[pid: 3354|app: 0|req: 1490/2208] 73.49.35.42 () {52 vars in 1194 bytes} [Mon May 14 16:59:16 2018] POST /password_reset/ => generated 0 bytes in 22 msecs (HTTP/1.1 302) 4 headers in 138 bytes (1 switches on core 0)
[pid: 3355|app: 0|req: 719/2209] 73.49.35.42 () {46 vars in 1035 bytes} [Mon May 14 16:59:16 2018] GET /password_reset/done/ => generated 2877 bytes in 40 msecs (HTTP/1.1 200) 3 headers in 102 bytes (1 switches on core 0)

我必须进行哪些更改才能让 Django 将我在 /password_reset 模板中输入的电子邮件通过电子邮件发送?

【问题讨论】:

    标签: django email nginx uwsgi


    【解决方案1】:

    我将以下内容添加到local_settings.py,此错误消失了。

    DEFAULT_FROM_EMAIL = ADMIN_EMAIL
    SERVER_EMAIL = ADMIN_EMAIL
    

    【讨论】:

      猜你喜欢
      • 2013-12-18
      • 1970-01-01
      • 2021-08-05
      • 1970-01-01
      • 1970-01-01
      • 2020-09-26
      • 1970-01-01
      • 1970-01-01
      • 2015-07-31
      相关资源
      最近更新 更多