首页 > 解决方案 > Django 发送 gmail 失败

问题描述

我在设置文件中配置了 gmail,如下所示:

#gmail_send/settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'yoorusername@gmail.com'
EMAIL_HOST_PASSWORD = 'key' #past the key or password app here
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'default from email'

我从谷歌打开了不太安全的应用程序访问,但它仍然无法正常工作

这是错误:

SMTPSenderRefused at /register
(530, b'5.7.0 Authentication Required. Learn more at\n5.7.0  https://support.google.com/mail/?p=WantAuthError n6sm1130142pgm.79 - gsmtp', '"default from email"')
Request Method: POST
Request URL:    http://127.0.0.1:8000/register
Django Version: 3.2.3
Exception Type: SMTPSenderRefused
Exception Value:    
(530, b'5.7.0 Authentication Required. Learn more at\n5.7.0  https://support.google.com/mail/?p=WantAuthError n6sm1130142pgm.79 - gsmtp', '"default from email"')

标签: djangogmail

解决方案


推荐阅读