I deploy my django project and my contact form stoped work. I tried some tips find on stack, but it doesn't works, help me plz.
Here my local settings:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'password'
and my view:
def contact_form(request):
form = ContactForm(request.POST or None)
if form.is_valid():
message = form.cleaned_data.get('message')
email = form.cleaned_data.get('email')
subject = 'contact form'
from_email = email
to_email = (settings.EMAIL_HOST_USER,)
contact_message = '%s, from %s' %(message, from_email)
send_mail(subject, contact_message, from_email, to_email, fail_silently=False)
form = ContactForm()
request.session.set_expiry(10)
request.session['pause'] = True
return render(request, 'contact_form.html', {'form':form})
Now when I send message I have "Internal Server Error".
I contacted Baterson via Skype and solved this issue together. the production server didnot support smtp settings and there were some other bugs. So we fixed them all and finally decided to just use:
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
all is working now
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With