有没有办法在 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/