我正在嘗試為我的投資組合建立一個聯系我的表格,但我遇到了問題。TracebackFile "..\env\lib\site-packages\django\core\handlers\exception.py", line 34, in inner SMTPSenderRefused at /(530, b'5.5.1 Authentication Required. Learn more at\n5.5.1 https://support.google.com/mail/?p=WantAuthError c17sm3159820ild.31 -gsmtp', '[email protected]')views.pydef index_view(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): # Send email goes here sender_name = form.cleaned_data['name'] sender_email = form.cleaned_data['email'] message = "{0} has sent you a new message:\n\n{1}".format(sender_name, form.cleaned_data['message']) send_mail('New Enquiry', message, sender_email, ['[email protected]']) return HttpResponse("Thanks for contacting, We will be in touch soon!") else: form = ContactForm() return render(request, 'index.html', {'form': form })Settings.pyEMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'EMAIL_HOST = 'smtp.gmail.com'EMAIL_USE_TLS = TrueEMAIL_PORT = 587EMAIL_HOST_USER = os.environ.get('EMAIL_USER')EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PWD')Forms.pyfrom django import forms class ContactForm(forms.Form): name = forms.CharField(max_length=100) email = forms.EmailField() subject = forms.CharField(max_length=100) message = forms.CharField(widget=forms.Textarea)我進入了我在 Gmail 上的設置,看看安全設置中是否存在阻止我接收表單提交的內容,我嘗試更改允許訪問不太安全的應用程序的安全設置。我應該選擇不同的電子郵件提供商還是有解決方法?
1 回答

胡子哥哥
TA貢獻1825條經驗 獲得超6個贊
您是否為您的 Gmail 帳戶啟用了 2 因素身份驗證?如果是這樣,您可能需要使用“應用程序密碼”,而不是您的常規電子郵件密碼。
https://support.google.com/accounts/answer/185833
添加回答
舉報
0/150
提交
取消