我在使用uWSGI和nginx的服务器上运行了一个Django应用程序。
在我的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
模板中输入的电子邮件?
答案 0 :(得分:0)
我将以下内容添加到local_settings.py
,此错误消失了。
DEFAULT_FROM_EMAIL = ADMIN_EMAIL
SERVER_EMAIL = ADMIN_EMAIL