django - 如何在不打开 "allow less secure apps"设置的情况下从 Gmail 发送电子邮件?

标签 django email smtp gmail

有没有办法在 Django 项目中发送电子邮件而不打开“允许安全性较低的应用程序”功能?必须使用 OAuth2 还是我可以使用 Google 的 API 发送它?

到目前为止,我只使用:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = '587'
EMAIL_HOST_USER = 'myemailaddress'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False

但这给了我一个 SMTPAuthenticationError,只有当我在 Google 中打开“允许安全性较低的应用程序”时它才会起作用。有没有办法在不使用 OAuth2 的情况下规避此问题并允许多个用户轻松登录该帐户?

最佳答案

Using the gmail app password through you can send the email not provide the actual password and no one can login in your account. Without enable less secure apps setting here is give the link try and it's work let me know if it right google or gmail app password

在它将实际密码更改为您的应用密码之后

setting.py 文件 EMAIL_HOST_PASSWORD = 'your app password' 由谷歌提供 其他常数不变

if you do not use 2 step email verification you need to use third party service here i give the link you see sendgrid

关于django - 如何在不打开 "allow less secure apps"设置的情况下从 Gmail 发送电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60236263/

相关文章:

php - 在 Centos 6.4 和 Nginx 服务器上使用 PHP 发送电子邮件

smtp - 无法连接到 "localhost"端口 25 的邮件服务器

JavaMail API 和 Tomcat 7 实现

python - 排除通用 CRUD View 中的字段

javascript - 无法检索从 jQuery 发布到 Django 的对象数组

java - 如何将 Internet mime 消息的所有内容复制到 Notes 中的正文项?

git - 如何在 Jenkins 电子邮件中包含 git changelog?

c# - 作为 AD 组发送电子邮件

django - django 管理中的错误语言

python - Django 模型没有将数据实时保存到数据库