0

JUST tried to link an email address to the simple form and the error continued to occur which I couldn't fix yet. can you please help me to understand what does this error actually mean. and the possible way to get rid of it.

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/contact/

Django Version: 1.8.5
Python Version: 3.5.0
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'newsletter')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')


Traceback:
File "C:\Users\Lokesh\AppData\Local\Programs\Python\Python35-32\lib\site-        packages\django\core\handlers\base.py" in get_response
132.                     response = wrapped_callback(request,   *callback_args,      **callback_kwargs)
File "c:\Windows\SysWOW64\src\newsletter\views.py" in contact
66.                 fail_silently=True)
File "C:\Users\Lokesh\AppData\Local\Programs\Python\Python35-32\lib\site-  packages\django\core\mail\__init__.py" in send_mail
62.     return mail.send()
File "C:\Users\Lokesh\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\mail\message.py" in send
303.         return self.get_connection(fail_silently).send_messages([self])
File "C:\Users\Lokesh\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\mail\backends\smtp.py" in send_messages
100.             new_conn_created = self.open()
File "C:\Users\Lokesh\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\mail\backends\smtp.py" in open
58.             self.connection = connection_class(self.host, self.port, **connection_params)
File "C:\Users\Lokesh\AppData\Local\Programs\Python\Python35- 32\lib\smtplib.py" in __init__
251.             (code, msg) = self.connect(host, port)
File "C:\Users\Lokesh\AppData\Local\Programs\Python\Python35-32\lib\smtplib.py" in connect
335.         self.sock = self._get_socket(host, port, self.timeout)
File "C:\Users\Lokesh\AppData\Local\Programs\Python\Python35-32\lib\smtplib.py" in _get_socket
306.                                         self.source_address)
File "C:\Users\Lokesh\AppData\Local\Programs\Python\Python35-32\lib\socket.py" in create_connection
689.     for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Users\Lokesh\AppData\Local\Programs\Python\Python35- 32\lib\socket.py" in getaddrinfo
728.     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):

Exception Type: gaierror at /contact/
Exception Value: [Errno 11001] getaddrinfo failed
Lokesh Tiwari
  • 61
  • 1
  • 8

1 Answers1

0

Recently, I faced this same problem, and I was able to fix it by making sure that in my django settings.py, where my email setting snippet is that none of my email setting variable value should by any means carry a space as that will change your email endpoint.

IN MY CASE OLD CODE(The error in this code is in EMAIL_HOST):

EMAIL_HOST = 'smtp.gmail.com '
EMAIL_HOST_USER ='youremail@gmail.com'
EMAIL_HOST_PASSWORD = 'your google gmail app generated password'
EMAIL_USE_TLS = True
EMAIL_PORT = 587

FORMATED CODE, THE WORKING ONE:

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER ='youremail@gmail.com'
EMAIL_HOST_PASSWORD = 'your google gmail app generated password'
EMAIL_USE_TLS = True
EMAIL_PORT = 587

I hope this works for you!

Gabriel J
  • 66
  • 7