我部署了我的django项目和我的联系表格stoped work.我在堆栈上尝试了一些提示,但它不起作用,请帮助我PLZ.
这是我的本地设置:
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'
和我的观点:
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})
现在,当我发送消息时,我有"内部服务器错误".