我正尝试使用Django sendmail 发送电子邮件,但是由于某种原因,它引发了此错误,并表明问题出在我的 email 上,即['abrarshahriar360@gmail.com'],
行。在开发服务器上运行良好,当我使用heroku部署它后,一切都运行良好,正当我尝试发送电子邮件时,它就显示了这一点。我已关闭了两因素身份验证,而打开的安全性较低的应用也已打开。为何仍会显示此错误?预先感谢!
我的views.py:
def appointment(request):
if request.method == "POST":
your_name = request.POST['your-name']
your_phone = request.POST['your-phone']
your_email = request.POST['your-email']
your_address = request.POST['your-address']
your_schedule = request.POST['your-schedule']
your_date = request.POST['your-date']
your_message = request.POST['your-message']
appointment = "Name: " + your_name + " " + "Phone: " + your_phone + " " + "Email: " + your_email + " " + "Address: " + your_address + " " + "Schedule: " + your_schedule + " " + "Appointment Date: " + your_date + " " + "Message: " + your_message
send_mail(
'Appointment request form ' + your_name,
appointment,
your_email,
['abrarshahriar360@gmail.com'],
)
return render(request, 'appointment.html', {
'your_name' : your_name,
'your_phone' : your_phone,
'your_email' : your_email,
'your_address' : your_address,
'your_schedule' : your_schedule,
'your_date' : your_date,
'your_message' : your_message
})
else:
return render(request, 'home.html', {})
我的settings.py:
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
# Email Settings
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'abrarshahriar360@gmail.com'
EMAIL_HOST_PASSWORD = os.environ.get('Email_PASS')
EMAIL_USE_TLS = True
django_heroku.settings(locals())
答案 0 :(得分:0)
这实际上是我的问题。我传递了错误的上下文变量。所以它抛出了那个错误