Django email sending error - python

i'm trying to get a contact form on a personal site to work.
i'm using the smtp outlook.
Right now it gives me the following error:
Traceback:
Environment:
Request Method: POST
Request URL: *******
Django Version: 1.8.1
Python Version: 3.4.0
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles')
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 "/home/Nmaster88/Ngranja/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/Nmaster88/Ngranja/Ngranja/Ngranja/views.py" in sendmail
23. send_mail(request.POST['contactSubject'],"From: "+request.POST['contactEmail']+'\n\n'+request.POST['contactMessage'],request.POST['contactEmail'],['nunomaster_#hotmail.com'],)
File "/home/Nmaster88/Ngranja/lib/python3.4/site-packages/django/core/mail/__init__.py" in send_mail
62. return mail.send()
File "/home/Nmaster88/Ngranja/lib/python3.4/site-packages/django/core/mail/message.py" in send
303. return self.get_connection(fail_silently).send_messages([self])
File "/home/Nmaster88/Ngranja/lib/python3.4/site-packages/django/core/mail/backends/smtp.py" in send_messages
100. new_conn_created = self.open()
File "/home/Nmaster88/Ngranja/lib/python3.4/site-packages/django/core/mail/backends/smtp.py" in open
58. self.connection = connection_class(self.host, self.port, **connection_params)
File "/usr/lib/python3.4/smtplib.py" in __init__
242. (code, msg) = self.connect(host, port)
File "/usr/lib/python3.4/smtplib.py" in connect
321. self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python3.4/smtplib.py" in _get_socket
292. self.source_address)
File "/usr/lib/python3.4/socket.py" in create_connection
509. raise err
File "/usr/lib/python3.4/socket.py" in create_connection
500. sock.connect(sa)
Exception Type: ConnectionRefusedError at /
Exception Value: [Errno 111] Connection refused
my settings:
EMAIL_HOST = 'smtp-mail.outlook.com'
EMAIL_HOST_USER = 'myemail#hotmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 25
EMAIL_USE_TLS = True
view file:
from django.http import HttpResponseRedirect
from django.core.mail import send_mail
from django.shortcuts import render
def sendmail(request):
errors=[]
if request.method == 'POST':
if not request.POST.get('contactName',''):
errors.append('Coloca um nome.')
if not request.POST.get('contactEmail',''):
errors.append('Coloca um email.')
if not request.POST.get('contactSubject',''):
errors.append('Coloca um assunto.')
if not request.POST.get('contactMessage',''):
errors.append('Coloca um assunto.')
if not errors:
subject=request.POST['contactSubject']
email=request.POST['contactEmail']
message=request.POST['contactMessage']
send_mail(subject,"From: "+email+'\n\n'+message,email,['myemail#hotmail.com'], fail_silently=False)
return HttpResponseRedirect('/thankyou/')
return render(request, "mypage.html", {'errors': errors})
Does anyone has a clue on what is wrong?
If necessary i can give more info on the app
[EDIT]
I'm hosting the page at pythonanywhere.com, does the error have something to do with the server?
[EDIT] SOLVED
Pythonanywhere for free users only works for Gmail, and i had to give it permission for less secure apps! Now it works fine.

Try using use_ssl=True in your SMTP settings and changing the port to 465.
You can directly refer to Django SMTP options for list of all the settings you can tweak.
Also please mention which Django version you are using for building your app?

Related

Error in sending mail via STMP in aws elasticbeanstalk

I am unable to resolve this error. I am running django. It works properly on my local, but I have deployed the code to aws elasticbeanstalk where it throws the below error.
Also my smtp configuration is something like this.
I have also tried to ALLOW low secure apps in Google settings.
But nothing seems to work.
# SMTP configuration
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'email#gmail.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_USE_TLS = True
Environment:
Request Method: POST
Request URL: http://odm-masala-app-env.eba-ijhfppue.us-west-2.elasticbeanstalk.com/accounts/register/
Django Version: 3.1
Python Version: 3.7.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'category',
'accounts',
'store',
'carts',
'orders',
'admin_honeypot',
'storages']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django_session_timeout.middleware.SessionTimeoutMiddleware']
Traceback (most recent call last):
File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/django/core/handlers/base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/app/current/accounts/views.py", line 53, in register
send_email.send()
File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/django/core/mail/message.py", line 284, in send
return self.get_connection(fail_silently).send_messages([self])
File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
new_conn_created = self.open()
File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 69, in open
self.connection.login(self.username, self.password)
File "/usr/lib64/python3.7/smtplib.py", line 730, in login
raise last_exception
File "/usr/lib64/python3.7/smtplib.py", line 721, in login
initial_response_ok=initial_response_ok)
File "/usr/lib64/python3.7/smtplib.py", line 642, in auth
raise SMTPAuthenticationError(code, resp)
Exception Type: SMTPAuthenticationError at /accounts/register/
Exception Value: (534, b'5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbt\n5.7.14 JzmJlDR_KXwRjsGoeGbUwfJiFaseGdN7r4Tr5kVIBAWkZ_KxJtmoZ21tvxssaWR96lYr1\n5.7.14 1McFMOBeAoLgjKAhaZSf7Z0H7mCYUPyXbKlQ-CmDohYCNFK3GmWZG47EBOB2uOnH>\n5.7.14 Please log in via your web browser and then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 63sm12202837pfz.119 - gsmtp')
This is because gmail uses captcha verification, please try disabling it from below link.
https://accounts.google.com/DisplayUnlockCaptcha

django-rest-registration 0.5.1 throws RESET_PASSWORD_VERIFICATION_URL and RESET_PASSWORD_VERIFICATION_URL are not set, even if they are set

I am creating REST api, with Django Rest Framework, and first of all I have to give users the way to register. I saw django-rest-registration as easy way to make this, but when I did everything as is said in Quickstart, my terminal throws those errors:
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
?: (rest_registration.E001) RESET_PASSWORD_VERIFICATION_URL is not set
?: (rest_registration.E004) VERIFICATION_FROM_EMAIL is not set
System check identified 2 issues (0 silenced).
Here's my code:
settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'rest_registration',
'app',
]
REST_REGISTRATION = {
'REGISTER_VERIFICATION_ENABLED': False,
'REGISTER_EMAIL_VERIFICATION_ENABLED': False,
'RESET_PASSWORD_VERIFICATION_ENABLED': False,
}
urlpatterns:
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('app.urls')),
path('accounts/', include('rest_registration.api.urls')),
]
But, when I tried to change REST_REGISTRATION to this:
REST_REGISTRATION = {
'REGISTER_VERIFICATION_URL': 'https://frontend-host/verify-user/',
'RESET_PASSWORD_VERIFICATION_URL': 'https://frontend-host/reset-password/',
'REGISTER_EMAIL_VERIFICATION_URL': 'https://frontend-host/verify-email/',
'VERIFICATION_FROM_EMAIL': 'no-reply#example.com',
}
and I submitted the request, I saw another error:
ConnectionRefusedError at /accounts/register/
+ Traceback:
Environment:
Request Method: POST
Request URL: http://localhost:8000/accounts/register/
Django Version: 2.2.3
Python Version: 3.7.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'rest_registration',
'app']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/views/generic/base.py" in view
71. return self.dispatch(request, *args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
495. response = self.handle_exception(exc)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/views.py" in handle_exception
455. self.raise_uncaught_exception(exc)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
492. response = handler(request, *args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/decorators.py" in handler
55. return func(*args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_registration/api/views/register.py" in register
96. send_verification_notification(user, signer, template_config)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_registration/notifications/email.py" in send_verification_notification
24. send_notification(notification)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_registration/notifications/email.py" in send_notification
209. notification.send()
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/mail/message.py" in send
291. return self.get_connection(fail_silently).send_messages([self])
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py" in send_messages
103. new_conn_created = self.open()
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py" in open
63. self.connection = self.connection_class(self.host, self.port, **connection_params)
File "/usr/lib/python3.7/smtplib.py" in __init__
251. (code, msg) = self.connect(host, port)
File "/usr/lib/python3.7/smtplib.py" in connect
336. self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python3.7/smtplib.py" in _get_socket
307. self.source_address)
File "/usr/lib/python3.7/socket.py" in create_connection
727. raise err
File "/usr/lib/python3.7/socket.py" in create_connection
716. sock.connect(sa)
Exception Type: ConnectionRefusedError at /accounts/register/
Exception Value: [Errno 111] Connection refused
I added email settings:
# Email settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 8000
And now when I submit post I just see this in terminal: [22/Sep/2019 14:44:54] "POST /accounts/register/ HTTP/1.1" 400 13646 (Its drawn with red font, if it matters). And webpage is loading infinitley.

OperationalError at /result unable to open database file

I have this error for 2 days now I triyed everything in the other topics nothings works for me. The code of the app was written in linux, but i got the folder and connected it to my project as an app, in this project there is 3 apps that are connecting good to the database, only this one gives an error unable to open data base. I'm using Windows on Localhost, a friend triyed on windows and it's working for him, only for me not working.
Note : When I go to localhost:8000/admin I can see the model created on the database.
PLEASE HELP!
Django Version: 2.2.3
I have tryied to give permissions of the folder on it's proprieties to read and write, tryied to change path of DIR, I switched from sqlite3 to postgres, made full path in database and not full one, triyed all the recommandations on topics but still shows the error
Settings. py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'devee',
'USER': 'postgres',
'PASSWORD': 'thepasswordichoosed',
'HOST': 'localhost',
'PORT': '5432',
}
}
Environment:
Request Method: POST
Request URL: http://localhost:8000/result
Django Version: 2.2.3
Python Version: 3.7.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dashboard',
'account',
'analyse']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\handlers\exception.py" in inner
34. response = get_response(request)
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\handlers\base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\handlers\base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\django\views\decorators\csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "C:\Users\I500913\Desktop\Projets\final\analyse\views.py" in analyse_result
22. seo_score, report = scrapper(website)
File "C:\Users\I500913\Desktop\Projets\final\analyse\seo_scrapper.py" in scrapper
411. sbl = SafeBrowsingList(api_key)
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\gglsbl\client.py" in __init__
35. self.storage = SqliteStorage(db_path, timeout=timeout)
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\gglsbl\storage.py" in __init__
73. self.db = sqlite3.connect(db_path, timeout)
Exception Type: OperationalError at /result
Exception Value: unable to open database file

Setting proxy in Django

I am trying to send email is using django.core.mail.send_mail(). However I am getting the following error when I try submit the form.
Here is the error I am getting:
Request Method: POST
Request URL: http://127.0.0.1:8000/contact/
Django Version: 1.8.10
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'newsletter',
'Contact')
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 "/home/sumit/Desktop/Home/Django/local/lib/python2.7/site-packages/Django-1.8.10-py2.7.egg/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/sumit/Desktop/Home/Django/src/Contact/views.py" in contact
25. fail_silently=False
File "/home/sumit/Desktop/Home/Django/local/lib/python2.7/site-packages/Django-1.8.10-py2.7.egg/django/core/mail/__init__.py" in send_mail
62. return mail.send()
File "/home/sumit/Desktop/Home/Django/local/lib/python2.7/site-packages/Django-1.8.10-py2.7.egg/django/core/mail/message.py" in send
303. return self.get_connection(fail_silently).send_messages([self])
File "/home/sumit/Desktop/Home/Django/local/lib/python2.7/site-packages/Django-1.8.10-py2.7.egg/django/core/mail/backends/smtp.py" in send_messages
100. new_conn_created = self.open()
File "/home/sumit/Desktop/Home/Django/local/lib/python2.7/site-packages/Django-1.8.10-py2.7.egg/django/core/mail/backends/smtp.py" in open
58. self.connection = connection_class(self.host, self.port, **connection_params)
File "/usr/lib/python2.7/smtplib.py" in __init__
256. (code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py" in connect
316. self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.7/smtplib.py" in _get_socket
291. return socket.create_connection((host, port), timeout)
File "/usr/lib/python2.7/socket.py" in create_connection
553. for res in getaddrinfo(host, port, 0, SOCK_STREAM):
Exception Type: gaierror at /contact/
Exception Value: [Errno -2] Name or service not known
This is my views.py file.
from django.shortcuts import render
from .forms import ContactUsForm
from django.core.mail import send_mail
from django.conf import settings
def contact(request):
form = ContactUsForm(request.POST or None)
context = {
"title" : "Contact",
"form" : form,
}
if form.is_valid():
form_email = form.cleaned_data.get("email")
form_full_name = form.cleaned_data.get("full_name")
subject = "Sent via django"
from_email = settings.EMAIL_HOST_USER
to_email = [form_email]
contact_message = "Thank you %s " %(form_full_name)
send_mail(subject,
contact_message,
from_email,
to_email,
fail_silently=False
)
context = {
"title" : "Thank you for your feedback ! "
}
form.save()
return render(request, "contact.html", context)
forms.py:
from django import forms
from .models import ContactUs
class ContactUsForm(forms.ModelForm):
class Meta:
model = ContactUs
fields = ["full_name", "email", "message"]
models.py
from django.db import models
# Create your models here.
class ContactUs(models.Model):
full_name = models.CharField(max_length=120, blank=True)
email = models.EmailField()
message = models.CharField(max_length=100, blank=True)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
updated = models.DateTimeField(auto_now=True, auto_now_add=False)
def __unicode__(self):
return self.email
I have set proxy variables in my terminal using:
export https_proxy="https://username:password#myproxy:myport"
export http_proxy="http://username:password#myproxy:myport"
export socks_proxy="socks://username:password#myproxy:myport"
export ftp_proxy="ftp://username:password#myproxy:myport"
How do I fix this error? Please help.
Have you set required parameters in settings.py file?
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
And its gaierror In your HOST parameter it should be :
HOST = ' ' (without space)
Don't use with space HOST = ' '

gaierror [Errno 8] when send_mail with Django python and gmail

I'm new with Django an Python.
I was following this tutorial "Try Django 16"
I don't get it work. I added fail_silent=false to get the error.
[Errno 8] nodename nor servname provided, or not known
Is there anyone who can help me find this problem?
gaierror at /thank-you/
[Errno 8] nodename nor servname provided, or not known
Request Method: POST
Request URL: http://127.0.0.1:8000/thank-you/
Django Version: 1.6.5
Exception Type: gaierror
Exception Value:
[Errno 8] nodename nor servname provided, or not known
Exception Location: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py in create_connection, line 553
Python Executable: /usr/bin/python
Python Version: 2.7.5
Python Path:
['/Users/andremensink/Desktop/skillshare/src',
'/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages']
Server time: Sat, 28 Jun 2014 13:23:10 +0000
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/thank-you/
Django Version: 1.6.5
Python Version: 2.7.5
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'south',
'signups')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/andremensink/Desktop/skillshare/src/signups/views.py" in thankyou
40. send_mail(subject,message,from_email,to_list,fail_silently=False)
File "/Library/Python/2.7/site-packages/django/core/mail/__init__.py" in send_mail
50. connection=connection).send()
File "/Library/Python/2.7/site-packages/django/core/mail/message.py" in send
274. return self.get_connection(fail_silently).send_messages([self])
File "/Library/Python/2.7/site-packages/django/core/mail/backends/smtp.py" in send_messages
87. new_conn_created = self.open()
File "/Library/Python/2.7/site-packages/django/core/mail/backends/smtp.py" in open
48. local_hostname=DNS_NAME.get_fqdn())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py" in __init__
250. (code, msg) = self.connect(host, port)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py" in connect
310. self.sock = self._get_socket(host, port, self.timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py" in _get_socket
285. return socket.create_connection((host, port), timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py" in create_connection
553. for res in getaddrinfo(host, port, 0, SOCK_STREAM):
Exception Type: gaierror at /thank-you/
Exception Value: [Errno 8] nodename nor servname provided, or not known
The code in python is:
#--django stuff
from django.conf import settings
from django.contrib import messages
from django.core.mail import send_mail #EmailMessage#send_mail
from django.shortcuts import render, render_to_response, RequestContext, HttpResponsePermanentRedirect
subject = 'This is the subject'
message = 'Welcome to the list and enjoy your product.\n This is the message.'
from_email = settings.EMAIL_HOST_USER
to_list = [save_it.email,settings.EMAIL_HOST_USER]
send_mail(subject,message,from_email,to_list,fail_silently=False)
in the settings is defined:
#for gmail or google apps
EMAIL_USE_TLS = True
EMAIL_HOST = 'smpt.gmail.com'
EMAIL_HOST_USER = 'mymail#gmail.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 587
ACCOUNT_EMAIL_VERIFICATION = 'none'
EMAIL_HOST = 'smpt.gmail.com'
What is smpt?
should be EMAIL_HOST = 'smtp.gmail.com'
http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol

Categories