Ich habe diese django-contact-form App installiert. Wenn ich per Kontaktformular eine E-Mail an mein Google Mail-Konto senden möchte, erhalte ich keinen Fehler und werde zu meiner contact_form_sent.html weitergeleitet, aber es wird keine E-Mail gesendet. Kann mir jemand bei der Fehlersuche helfen? Ist das ein Problem des SMTP-Servers, weil ich von localhost aus teste ???Mail wird nicht von Django-Kontaktformular App gesendet und es gibt keine Fehlermeldung
Meine Konfigurationen sind wie folgt, es Patrick Beeson's ähnelt:
settings.py Ich habe bereits andere E-Mail-Konten und deren sachgemäßer Ports geprüft.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
#('***', '***@googlemail.com'),
)
MANAGERS = ADMINS
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = '********'
EMAIL_HOST_USER = '******@googlemail.com'
EMAIL_PORT = 587 #465 or 587
#EMAIL_SUBJECT_PREFIX = 'Django Test mail'
EMAIL_USE_TLS = True
urls.py
(r'^contact/', include('contact_form.urls')),
contact_form.html
...
<form method="POST">
<ol>
{{ form.as_p }}
<li>
<input type="submit" name="submit" value={% trans "Senden" %} />
<div class="clr"></div>
</li>
</ol>
</form>
...
contact_form.txt
{{ name }}
{{ email }}
{{ body }}
contact_form_sent.html
{% block content %}
<h2>{% trans "Your message was sent." %}</h2>
{% endblock %}
contact_form_subject.txt
message from {{ name }}
EDITED
wenn action="."
in meinem contact_form.html Einstellung und das Hinzufügen von print request.POST
bekomme ich diese in meinem Entwicklung ent-Server auf localhost, nach dem Klick auf Submit-Button:
<QueryDict: {u'body': [u'This is my Test message for you !!\r\n\r\nBest Regards\r\nMr. NoOne'], u'name': [u'testname'], u'submit': [u'Send'], u'email': [u'[email protected]
com']}>
EDITED
Wenn ich meine eigene view.py schreiben bekomme ich diesen Fehler:
Request Method: POST
Request URL: http://127.0.0.1:8000/en/contact/
Exception Type: error
Exception Value:
(10065, 'No route to host')
Exception Location: C:\Python25\lib\smtplib.py in connect, line 310
Python Executable: C:\Python25\python.exe
Python Version: 2.5.0
Python Path: ['H:\\webpage', 'C:\\WINDOWS\\system32\\python25.zip', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site-packages']
meine neue eigene views.py sieht so aus:
from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.core.mail import send_mail
from contact_form.forms import ContactForm
def email_contact(request, form_class=ContactForm, template_name='contact_form/contact_form.html'):
form = form_class(data=request.POST, files=request.FILES, request=request)
if request.method == "POST":
send_mail('Subject here', 'Here is the message.', '[email protected]', ['[email protected]'], fail_silently=False)
print request.POST
return render_to_response(template_name, { 'form': form }, context_instance=RequestContext(request))
Was läuft hier falsch?
Ich habe es mit smtp.googlemail.com getestet, aber immer noch das gleiche Problem. Gibt es eine Möglichkeit zum Debuggen? – saeed
Ich weiß, ich hatte einmal ähnliche Probleme. Ich hoffe, ich habe das Repo noch irgendwo, lass mich nach dir Ausschau halten. –
Ich würde jede Hilfe schätzen, weil ich verrückt werde, ohne dass eine Fehlermeldung ausgegeben wird. Es ist wie ein Ratespiel. – saeed