SMTPConnectError when using Django

2024/10/7 4:30:41

I'm using django-registration for handling of users registration. I tried to signup in order to test it, after testing it, I got this error

SMTPConnectError at /accounts/register/

Being trying to find a solution yet no success!

Full Traceback

Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python27\lib\site-packages\registration\views.py" in register
187.  new_user = backend.register(request, **form.cleaned_data)
File "C:\Python27\lib\site-packages\registration\backends\default\__init__.py" in register
79.    password, site) File "C:\Python27\lib\site-packages\django\db\transaction.py" in  inner
209.       return func(*args, **kwargs)  File "C:\Python27\lib\site-  packages\registration\models.py" in create_inactive_user85.     registration_profile.send_activation_email(site)File "C:\Python27\lib\site-packages\registration\models.py" in send_activation_email
264.         self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
File "C:\Python27\lib\site-packages\django\contrib\auth\models.py" in email_user374.         send_mail(subject, message, from_email, [self.email])File "C:\Python27\lib\site-packages\django\core\mail\__init__.py" in send_mail61.       connection=connection).send()File "C:\Python27\lib\site-packages\django\core\mail\message.py" in send248.  return self.get_connection(fail_silently).send_messages([self])File "C:\Python27\lib\site-packages\django\core\mail\backends\smtp.py" in    send_messages85.    new_conn_created = self.open()File "C:\Python27\lib\site-packages\django\core\mail\backends\smtp.py" in open48.       local_hostname=DNS_NAME.get_fqdn())File "C:\Python27\lib\smtplib.py" in __init__251.                 raise SMTPConnectError(code, msg)Exception Type: SMTPConnectError at /accounts/register/Exception Value: (451, 'Request action aborted on MFE proxy, SMTP server is not  available.')

In Settings.py

EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'EMAIL_USE_TLS=TrueEMAIL_HOST='smtp.test.com'EMAIL_HOST_USER='[email protected]'EMAIL_HOST_PASSWORD='f88lm'EMAIL_PORT=587DEFAULT_FROM_EMAIL = '[email protected]'SERVER_EMAIL = '[email protected]'
Answer

Of course there is an error, you have given details for an SMPT server that doesn't exist so Django can't connect to it when trying to send email. While developing, either use the dummy email backend:

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

or run a test email server locally.

https://en.xdnf.cn/q/118862.html

Related Q&A

how to have a single search API using path parameters (No form used)

I have been using this view for searching a word as:db refers mongo connection (just for ref)@app.route(/) def index():return render_template(index.html)@app.route(/words-<word>, methods=[GET, PO…

understanding the return type of anonymous function lambda

I am trying to understand how can lambda function be used. def adder_func(a, b):return a + bprint(adder_func(4, 5))# trying with lambda print(list(lambda a, b: a + b))When trying to use lambda as a add…

What is the meaning of Failed building wheel for flask-mysqldb in pip3 install?

I have a MacBook Air with macOs Sonoma 14.0 and when I write in the terminal $ pip3 install flask-mysqldbI get the error:How can I fix this?

How do I install pygame for a new version of idle? (Windows) [duplicate]

This question already has answers here:Error on install Pygame(3.9) install (Win10) [duplicate](1 answer)Unable to install pygame on Python via pip (Windows 10)(6 answers)Closed 3 years ago.I installed…

How to parse a dynamic dom element?

I want to make a parser for scraping price, however I cant find the working method of parsing innerHTMLI dont know why, but selenium (getAttribute(innerHTML)), phantomjs (page.evaluation function(){ret…

Get a string in Shell/Python with subprocess

After this topic Get a string in Shell/Python using sys.argv , I need to change my code, I need to use a subprocess in a main.py with this function :def download_several_apps(self):subproc_two = subpro…

Python Indentation Error when there is no indent error [duplicate]

This question already has answers here:Im getting an IndentationError (or a TabError). How do I fix it?(6 answers)Closed 7 months ago.Is it me or the interpreter? I see no indentation error in my cod…

How to mark rgb colors on a colorwheel in python? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 8 months ago.Improv…

Cant get Selenium to loop through two dialogue box options correctly

So basically: the goal is to click on each symbol for each sector on this website, that pops up a table with contact details, I want to copy all of that information and store it in a file. Right now ev…

Is it possible to use a JSON Web Token/JWT in a pip.conf file?

Im trying to make it possible for my application to fetch a package from a private feed in Azure DevOps using pip and a pip.conf file. I dont want to use a PAT for obvious reasons, so Ive created a ser…