[Errno 61] Connection refused
TimeWtr opened this issue · 0 comments
TimeWtr commented
- project goal:register account using email and send verification message to email,not console these messages in shell
- .env file:
DJANGO_EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
DJANGO_EMAIL_HOST=smtpdm.163.com
DJANGO_EMAIL_USE_SSL=False
DJANGO_EMAIL_PORT=25
DJANGO_EMAIL_HOST_USER='95762725ld@163.com'
DJANGO_EMAIL_HOST_PASSWORD='GRDCGOUASMNEBSTH' # 开启smtp是的授权码
DJANGO_DEFAULT_FROM_EMAIL='标题<95762725ld@163.com>'
ACCOUNT_EMAIL_VERIFICATION = 'none'
-
problem: When DJANGO_EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend, project will throw exception: 'ConnectionRefusedError at /rest-auth/registration/ [Errno 61] Connection refused'. However, 'DJANGO_EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend' , the shell will get these messages. Why?
-
Traceback:
WARNING 2020-12-02 20:50:28,847 log 42709 123145385709568 Bad Request: /rest-auth/registration/
[02/Dec/2020 20:50:28] "POST /rest-auth/registration/ HTTP/1.1" 400 125
Internal Server Error: /rest-auth/registration/
Traceback (most recent call last):
File "/Users/apple/project/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/Users/apple/project/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/apple/project/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 74, in inner
return func(*args, **kwds)
File "/Users/apple/project/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/apple/project/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/apple/project/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/Users/apple/project/lib/python3.7/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "/Users/apple/project/lib/python3.7/site-packages/rest_auth/registration/views.py", line 46, in dispatch
return super(RegisterView, self).dispatch(*args, **kwargs)
File "/Users/apple/project/lib/python3.7/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/Users/apple/project/lib/python3.7/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/Users/apple/project/lib/python3.7/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/Users/apple/project/lib/python3.7/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/Users/apple/project/lib/python3.7/site-packages/rest_framework/generics.py", line 190, in post
return self.create(request, *args, **kwargs)
File "/Users/apple/project/lib/python3.7/site-packages/rest_auth/registration/views.py", line 65, in create
user = self.perform_create(serializer)
File "/Users/apple/project/lib/python3.7/site-packages/rest_auth/registration/views.py", line 81, in perform_create
None)
File "/Users/apple/project/lib/python3.7/site-packages/allauth/account/utils.py", line 215, in complete_signup
signal_kwargs=signal_kwargs,
File "/Users/apple/project/lib/python3.7/site-packages/allauth/account/utils.py", line 175, in perform_login
send_email_confirmation(request, user, signup=signup, email=email)
File "/Users/apple/project/lib/python3.7/site-packages/allauth/account/utils.py", line 346, in send_email_confirmation
email_address.send_confirmation(request, signup=signup)
File "/Users/apple/project/lib/python3.7/site-packages/allauth/account/models.py", line 62, in send_confirmation
confirmation.send(request, signup=signup)
File "/Users/apple/project/lib/python3.7/site-packages/allauth/account/models.py", line 169, in send
get_adapter(request).send_confirmation_mail(request, self, signup)
File "/Users/apple/project/lib/python3.7/site-packages/allauth/account/adapter.py", line 464, in send_confirmation_mail
self.send_mail(email_template, emailconfirmation.email_address.email, ctx)
File "/Users/apple/project/lib/python3.7/site-packages/allauth/account/adapter.py", line 136, in send_mail
msg.send()
File "/Users/apple/project/lib/python3.7/site-packages/django/core/mail/message.py", line 284, in send
return self.get_connection(fail_silently).send_messages([self])
File "/Users/apple/project/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
new_conn_created = self.open()
File "/Users/apple/project/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 62, in open
self.connection = self.connection_class(self.host, self.port, **connection_params)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/smtplib.py", line 336, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/smtplib.py", line 307, in _get_socket
self.source_address)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 727, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused