0

I've set up a cookiecutter-django project for testing and it worked just fine printing the confirmation email to the console. However, it's important to me to also test the actual sending of the emails and when I tried to adjust the settings for a local testing environment, it gave me a SMTP AUTH extension not supported by server. error after adding a new account.

I changed EMAIL_BACKEND to EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' and added the relevant EMAIL_HOST, EMAIL_PORT, EMAIL_HOST_USER, and EMAIL_HOST_PASSWORD settings in the local.py settings file.

I'm using a yahoo account that was set up for this purpose and worked just fine outside of Django.

I can't find anything in the cookie-cutter documentation about how to configure this and the Django documentation has been less than helpful.

Edit to add:

email settings:
EMAIL_PORT = 587
EMAIL_HOST = 'smtp.mail.yahoo.com'
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')

Full traceback:

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.
Mo Hertz
  • 31
  • 6
  • May you provide the `EMAIL_HOST` and the `EMAIL_PORT` you are using? From my point of view the [django docs on that topic](https://docs.djangoproject.com/en/2.0/topics/email/#smtp-backend) are clear. All this depends on the configuration of the SMTP server you want to talk to. Thats why the docs don't tell much about what might go wrong there - this is out of scope. – dahrens Jan 21 '18 at 02:27
  • Looks like [this method](https://docs.python.org/3/library/smtplib.html#smtplib.SMTP.login) raises the error. A full stacktrace would also be helpful for debugging this. – dahrens Jan 21 '18 at 02:38
  • Sorry bout that. I added the full traceback and the relevant SMTP settings. – Mo Hertz Jan 21 '18 at 04:10

1 Answers1

1

Looks like yahoo does not support authentication on port 587.

Based on this article (and a few others) you might try to use EMAIL_PORT = 465 together with EMAIL_USE_SSL = True or EMAIL_USE_TLS = True.

Here can find additional information about the different ports: What is the difference between ports 465 and 587?.

If you just created an account for this purpose you might want to consider using another email provider that provides usual authentication on port 587, which is defacto default today.

dahrens
  • 3,879
  • 1
  • 20
  • 38
  • That's really strange because I've been using port 587 with Yahoo for an earlier incarnation of this problem for months without any issues. I changed the settings and now I'm getting what appears to be a server timeout. `Connection unexpectedly closed` – Mo Hertz Jan 22 '18 at 02:27
  • Okay, so the port isn't wrong (587 works, 465 doesn't). Turns out that Django requires the username to be the full email address, while whatever I had before required it to be the username without the domain at the end. Thanks for the link. – Mo Hertz Jan 22 '18 at 02:31