我正在使用Django上的Forget Password
功能进行编码。当用户填写表格并单击“重置”按钮时,将发送重置邮件。但我在这里遇到麻烦,用户单击按钮后无法发送邮件。我使用sendtestmail
命令,成功发送邮件。而且,我定义的内容和邮件主题不在通过sendtestmail
命令进行检查时发送的电子邮件中。昨天我花了所有时间才能解决上述错误,但没有成功。有人可以帮我吗?
...
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER', 'vuthehuy.hus@gmail.com')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD', 'my_password_app')
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'Colo Shop <no-reply@localhost>')
urlpatterns = [
path('password_reset/', auth_view.PasswordResetView.as_view(
template_name='account/password_reset_form.html',
form_class=EmailForgotPassword,
email_template_name='account/password_reset_email.html',
subject_template_name='account/password_reset_subject.txt'
), name='password_reset'),
path('password_reset/done/', auth_view.PasswordResetDoneView.as_view(
template_name='account/password_reset_done.html'
), name='password_reset_done'),
path('password_reset/confirm/<uidb64>/<token>/', auth_view.PasswordResetConfirmView.as_view(
template_name='account/password_change.html'
), name='password_reset_confirm'),
path('password_reset/complete/', auth_view.PasswordResetCompleteView.as_view(
template_name='account/password_change_done.html'
), name='password_reset_complete'),
]