简体   繁体   English

Django 不发送服务器错误 (500) 电子邮件

[英]Django not sending Server Error (500) emails

I have a Django website hosted on a remote server.我在远程服务器上托管了一个 Django 网站。 Whenever I encounter a Server Error (500) I am supposed to get an email with more information about the error.每当我遇到Server Error (500)我都会收到一封电子邮件,其中包含有关该错误的更多信息。 I am not getting these emails.我没有收到这些电子邮件。

send_mail() works on this server through the shell. send_mail()通过外壳在此服务器上工作。 mail_admins() works on this server through the shell. mail_admins()通过 shell 在这个服务器上工作。 Triggering a Server Error (500) only displays the error on the page and no email is ever sent.触发Server Error (500)只会在页面上显示错误,并且不会发送任何电子邮件。

Here are what I believe to be the relevant settings for sending email as well as receiving error emails.以下是我认为发送电子邮件和接收错误电子邮件的相关设置。

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = 'me@gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'

SERVER_EMAIL = 'me@gmail.com'

ADMINS = [
        ('me', 'me@gmail.com'),
]

I solved the issue.我解决了这个问题。

The problem was that I was not restarting Gunicorn (and maybe Nginx) after making changes to settings.py.问题是我没有在对 settings.py 进行更改后重新启动 Gunicorn(可能还有 Nginx)。 I restarted Gunicorn with the proper email settings in settings.py and now everything works.我在 settings.py 中使用正确的电子邮件设置重新启动了 Gunicorn,现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM