When a new user signs up I get the following. If I then navigate to the site root the signup continues as normal.
https://app.getsentry.com/share/issue/37383334372e313239343637313230/
error: [Errno 111] Connection refused
File "django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "allauth/socialaccount/providers/oauth2/views.py", line 55, in view
return self.dispatch(request, *args, **kwargs)
File "allauth/socialaccount/providers/oauth2/views.py", line 125, in dispatch
return complete_social_login(request, login)
File "allauth/socialaccount/helpers.py", line 142, in complete_social_login
return _complete_social_login(request, sociallogin)
File "allauth/socialaccount/helpers.py", line 158, in _complete_social_login
ret = _process_signup(request, sociallogin)
File "allauth/socialaccount/helpers.py", line 49, in _process_signup
ret = complete_social_signup(request, sociallogin)
File "allauth/socialaccount/helpers.py", line 167, in complete_social_signup
signal_kwargs={'sociallogin': sociallogin})
File "allauth/account/utils.py", line 167, in complete_signup
signal_kwargs=signal_kwargs)
File "allauth/account/utils.py", line 128, in perform_login
send_email_confirmation(request, user, signup=signup)
File "allauth/account/utils.py", line 296, in send_email_confirmation
signup=signup)
File "allauth/account/models.py", line 58, in send_confirmation
confirmation.send(request, signup=signup)
File "allauth/account/models.py", line 122, in send
get_adapter().send_confirmation_mail(request, self, signup)
File "allauth/account/adapter.py", line 369, in send_confirmation_mail
ctx)
File "allauth/account/adapter.py", line 110, in send_mail
msg.send()
File "django/core/mail/message.py", line 303, in send
return self.get_connection(fail_silently).send_messages([self])
File "django/core/mail/backends/smtp.py", line 100, in send_messages
new_conn_created = self.open()
File "django/core/mail/backends/smtp.py", line 58, in open
self.connection = connection_class(self.host, self.port, **connection_params)
File "python2.7/smtplib.py", line 256, in __init__
(code, msg) = self.connect(host, port)
File "python2.7/smtplib.py", line 316, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "python2.7/smtplib.py", line 291, in _get_socket
return socket.create_connection((host, port), timeout)
File "python2.7/socket.py", line 571, in create_connection
raise err
It looks like it's trying to send email and failing. While this should generate a report it shouldn't throw a 500 on the frontend.
This is a deployment/configuration issue of your project. It is not something that should be handled/solved in allauth (otherwise, each and every Django app that sends out email would need its own fix).
This is a deployment/configuration issue of your project. It is not something that should be handled/solved in allauth (otherwise, each and every Django app that sends out email would need its own fix).
To expand on this slightly - Django's mail sending has a fail_silently option, that prevents mail errors from raising, which Django uses itself in some cases.
However django-allauth doesn't set fail_silently=True -- perhaps it should?
(Note: Even with fail_silently, Django handles this case poorly, ticket filed to fix upstream: https://code.djangoproject.com/ticket/27210)
This is a deployment/configuration issue of your project. It is not something that should be handled/solved in allauth (otherwise, each and every Django app that sends out email would need its own fix).
What if I need Signup process complete successfully despite of the fact if email was not able to send?
May be there is a temporary mail server unavailability. I will see that user was created but account not verified and send confirmation link once again.
Now it fires an error within allauth code and you have no idea (unless you dig into the code) what piece of default behavior was executed and what is not.
The best way would be introduce setting that will turn fail_silently on/off
Simply override this method in the adapter:
def send_mail(self, template_prefix, email, context):
msg = self.render_mail(template_prefix, email, context)
msg.send(fail_silently=...)
@pennersr a quick question here: I used pip install to install django allauth, and use Heroku which re-installs using pip. I am wondering if the best way to handle this situation is to simply download allauth in my app directory and make the changes to override. Is there a better way? Opinions?
@kisna72 There is no need to alter allauth.. simply pip install the regular version, and point settings.ACCOUNT_ADAPTER to yourproject.somewhere.YourAccountAdapter and put the send_mail method in there ...
Most helpful comment
Simply override this method in the adapter: