如何在不关闭“允许安全性较低的应用程序"的情况下从Gmail发送电子邮件,环境? [英] How to send emails from Gmail without turning off "allow less secure apps" setting?
问题描述
是否可以在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?
推荐答案
使用
gmail应用程序密码
通过您可以发送电子邮件,但未提供实际密码,也没有人可以登录您的帐户.如果未启用安全性较低的应用程序,请在此处进行设置,尝试链接,它可以正常工作
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 ='您的应用程序密码'
其他常数不变
如果您不使用两步电子邮件验证,则需要在此处使用第三方服务,我会给您提供链接,如果工作正常,请回答正确,所以让我知道正确与否
If it work make right answer so let me know right or not
这篇关于如何在不关闭“允许安全性较低的应用程序"的情况下从Gmail发送电子邮件,环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!