且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

django-allauth - 使用Gmail帐户发送电子邮件验证

更新时间:2022-11-17 07:41:44

当然,您可以设置您的Gmail帐户发送电子邮件。只需设置django的这些设置即可:

  EMAIL_USE_TLS = True 
EMAIL_HOST ='smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = DEFAULT_FROM_EMAIL ='gmail账户'
EMAIL_HOST_PASSWORD ='gmail密码'


I have setup allauth to send out an email for every new registered user so that their email can be verified. Right now I use the email_backend so that the email is sent to the terminal instead, and everything works fine.

But now I want to can set it all up so that an email is sent, and since I will (likely) not have a local email server at the host server, but instead use for example an gmail account to send the verification email. Is this at all possible?

Of course you can set your gmail account to send emails. Just set these settings for django:

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = DEFAULT_FROM_EMAIL = 'gmail account'
EMAIL_HOST_PASSWORD = 'gmail password'