3

我一直在努力让电子邮件在 Django 中工作以进行日志记录以及 500 和 404 错误,而在我的一生中,我无法让它工作。我有DEBUG=False和所有其他设置。我有以下电子邮件设置:

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 用于上述设置。我还有以下内容:

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',
)

还有什么我想念的吗?任何帮助表示赞赏。

4

1 回答 1

4

是的,不是ADMINS = ()接收SEND_BROKEN_LINK_EMAILS,而是接收MANAGERS = ()

https://docs.djangoproject.com/en/dev/ref/settings/#managers

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

在管理员下添加此权利,它应该可以工作:

MANAGERS = ADMINS

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

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

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

于 2012-07-21T07:18:03.827 回答