2014-06-28 11 views
7

Sono nuovo con Django un Python. Stavo seguendo questo tutorial "Try Django 16" Non riesco a farlo funzionare. Ho aggiunto fail_silent=false per ottenere l'errore.gaierror [Errno 8] quando send_mail con Django python e gmail

[Errno 8] nodename nor servname provided, or not known 

C'è qualcuno che può aiutarmi a trovare questo problema?

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 

Il codice in Python è:

#--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)  

nelle impostazioni è definito:

#for gmail or google apps 
EMAIL_USE_TLS = True 
EMAIL_HOST = 'smpt.gmail.com' 
EMAIL_HOST_USER = '[email protected]' 
EMAIL_HOST_PASSWORD = 'password' 
EMAIL_PORT = 587 
ACCOUNT_EMAIL_VERIFICATION = 'none' 
+0

Questo screenshot sembra riguardare un problema diverso competente. E dovresti comunque incollare il testo dell'errore piuttosto che l'immagine. –

+0

Il testo è posizionato al posto degli screenshot. Che tipo di problema potrebbe essere? – DreeOlee

+0

dov'è il tuo codice "invia email"? quali sono le impostazioni? l'errore sembra voler un messaggio "DA" o il nome della macchina, ma non l'ha capito. – johntellsall

risposta

Problemi correlati