首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法确定如何为cookiecutter-django配置电子邮件设置

无法确定如何为cookiecutter-django配置电子邮件设置
EN

Stack Overflow用户
提问于 2018-01-21 08:08:52
回答 1查看 521关注 0票数 0

我已经设置了一个用于测试的cookiecutter-django项目,它可以很好地将确认电子邮件打印到控制台。然而,测试邮件的实际发送对我来说很重要,当我试图调整本地测试环境的设置时,在添加新帐户后,它给了我一个SMTP AUTH extension not supported by server.错误。

我将EMAIL_BACKEND更改为EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend',并在local.py设置文件中添加了相关的EMAIL_HOSTEMAIL_PORTEMAIL_HOST_USEREMAIL_HOST_PASSWORD设置。

我正在使用一个雅虎账号,这个账号就是为这个目的而设立的,在Django之外工作得很好。

我在cookie-cutter文档中找不到任何关于如何配置它的东西,Django文档也没有什么帮助。

编辑以添加:

电子邮件设置:

EMAIL_PORT = 587

EMAIL_HOST = 'smtp.mail.yahoo.com'

EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')

完整回溯:

代码语言:javascript
复制
Internal Server Error: /accounts/signup/
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 53, in inner
    return func(*args, **kwds)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
    return view(request, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/views.py", line 210, in dispatch
    return super(SignupView, self).dispatch(request, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/views.py", line 79, in dispatch
    **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/views.py", line 188, in dispatch
    **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/views.py", line 102, in post
    response = self.form_valid(form)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/views.py", line 231, in form_valid
    self.get_success_url())
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/utils.py", line 188, in complete_signup
    signal_kwargs=signal_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/utils.py", line 151, in perform_login
    send_email_confirmation(request, user, signup=signup)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/utils.py", line 319, in send_email_confirmation
    signup=signup)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/models.py", line 60, in send_confirmation
    confirmation.send(request, signup=signup)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/models.py", line 166, in send
    get_adapter(request).send_confirmation_mail(request, self, signup)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/adapter.py", line 447, in send_confirmation_mail
    ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/allauth/account/adapter.py", line 140, in send_mail
    msg.send()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/mail/message.py", line 348, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/mail/backends/smtp.py", line 104, in send_messages
    new_conn_created = self.open()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/mail/backends/smtp.py", line 71, in open
    self.connection.login(force_str(self.username), force_str(self.password))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/smtplib.py", line 696, in login
    "SMTP AUTH extension not supported by server.")
smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server.
EN

回答 1

Stack Overflow用户

发布于 2018-01-21 19:25:17

似乎yahoo不支持在端口587上进行身份验证。

基于this article (和其他一些),您可以尝试将EMAIL_PORT = 465EMAIL_USE_SSL = True EMAIL_USE_TLS = True一起使用。

这里可以找到关于不同端口的其他信息:What is the difference between ports 465 and 587?

如果您刚刚为此创建了一个帐户,那么您可能需要考虑使用其他电子邮件提供商,该提供商在端口587上提供通常的身份验证,这实际上是目前的默认设置。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48362398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档