问题描述
是否可以在Django项目中发送电子邮件而无需启用允许安全性较低的应用程序"功能?必须使用OAuth2还是可以使用Google的API发送它?
Is there any way to send an email in a Django project without turning on the "allow less secure apps" feature? Is using OAuth2 a must or can I send it using Google's API?
到目前为止,我只使用:
So far, I just use:
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的情况下规避此问题,并允许多个用户轻松登录该帐户?
But this gives me an SMTPAuthenticationError, which only works when I turn on "allow less secure apps" in Google. Is there any way to circumvent this without using OAuth2 and allow multiple users to login to that account easily?
推荐答案
在将实际密码更改为
setting.py
文件 EMAIL_HOST_PASSWORD ='您的应用程序密码'
其他常数不变
如果工作正常,请回答正确,所以让我知道正确与否
If it work make right answer so let me know right or not
这篇关于如何在不关闭“允许安全性较低的应用程序"的情况下从Gmail发送电子邮件,环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!