Smpt django on production server

I am deploying a django project and my contact form is stopped. I tried to find some hints on the stack, but this does not work, help me plz.

Here are 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 = ' mymail@gmail.com ' EMAIL_HOST_PASSWORD = 'password' 

and my opinion:

 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 a message, I have an "Internal Server Error".

+5
source share
1 answer

I contacted Baterson via Skype and solved this problem together. the production server did not support smtp settings, as well as some other errors. Therefore, we fixed them all and finally decided to just use:

 EMAIL_HOST = 'localhost' EMAIL_PORT = 25 

everything works now

+3
source

Source: https://habr.com/ru/post/1239233/


All Articles