django电子邮件未发送(使用表格)

时间:2020-09-17 07:10:54

标签: django django-email

from django.http import HttpResponse, HttpResponseRedirect
from .forms import Contact 
from django.core.mail import send_mail
def contact(response):
    if response.method=="POST":
        form= Contact(response.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            email = form.cleaned_data['email']
            comment = form.cleaned_data['comment']
            subject= "COMMENTS"
            send_mail(subject,comment,email,['nafiyadargaw360@gmail.com'],fail_silently=True)
        return HttpResponseRedirect("/contact")
    else:
        form=Contact()
    context = {'form': form}
    template = 'contact/index.html'
    return render(response,template,context)

我填写表格时没有任何错误,但首先页面没有按照提示重定向到/ contact,但是当我尝试使用shell时,它会起作用

0 个答案:

没有答案