gpt4 book ai didi

Django 通过电子邮件发送错误

转载 作者:行者123 更新时间:2023-12-01 12:52:10 26 4
gpt4 key购买 nike

我一直在努力让电子邮件在 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',
)

还有什么我想念的吗?感谢您的帮助。

最佳答案

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

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

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

在 ADMINS 下添加它,它应该可以工作:

MANAGERS = ADMINS

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

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

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

关于Django 通过电子邮件发送错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11589124/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com