Django通过电子邮件发送错误 [英] Django emailing on errors

查看:139
本文介绍了Django通过电子邮件发送错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力让电子邮件在Django中进行登录以及500和404错误,对于我来说,我无法让它工作。我有 DEBUG = False 和所有其他设置。我有以下电子邮件设置:

I have been struggling to get the emailing to work in Django for logging as well as for 500 and 404 errors and for the life of me I cant get it to work. I have DEBUG=False and all the other settings. I have the below for the email settings:

EMAIL_HOST = 'host'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'username'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_SUBJECT_PREFIX = 'something'
EMAIL_USE_TLS = True
SERVER_EMAIL='blah@blah.com'

我在使用Amazon SES进行上述设置。我也有以下:

I'm using Amazon SES for the above settings. I also have the following:

SEND_BROKEN_LINK_EMAILS=True
ADMINS = (
    ('name', 'email'),
)
MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
)

还有什么我还没有?任何帮助都不胜感激。

Is there anything else I'm missing?? Any help is appreciated.

推荐答案

是的,不是 ADMINS =()收到 SEND_BROKEN_LINK_EMAILS ,它是 MANAGERS =()

Yep, it's not ADMINS = () that receives SEND_BROKEN_LINK_EMAILS, it's MANAGERS = ()

https://docs.djangoproject.com/en/dev/ref/设置/#管理员

https://docs.djangoproject.com/en/dev/howto/error-reporting/#errors

加入这个权限在ADMINS下,它应该工作:

Add this right under ADMINS and it should work:

MANAGERS = ADMINS

您可能还想在设置中指定EMAIL_BACKEND,例如假定SMTP:

You may also want to specify EMAIL_BACKEND in settings, e.g. assuming SMTP:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

https://docs.djangoproject.com/en/dev/ref/settings/#email-backend

这篇关于Django通过电子邮件发送错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆