简体   繁体   English

我的 django smtp g-suite 设置似乎不起作用

[英]My django smtp g-suite settings don't seem to be working

I am having issues connecting Django to google g-suite account:我在将 Django 连接到 google g-suite 帐户时遇到问题:

The settings are currently as follows:目前的设置如下:

SITE_ID = 1
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = 'noreply@mydomain.com'
EMAIL_HOST_PASSWORD = '16CharacterAppPassword'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

Setting I have tried: Note, comma separated the different settings I have tried in all possible combination我尝试过的设置:注意,逗号分隔了我在所有可能的组合中尝试过的不同设置

EMAIL_HOST = 'smtp.gmail.com', 'smtp-relay.gmail.com', 'mail.mydomain.com'
EMAIL_USE_TLS = True, False
EMAIL_USE_SSL = False, True
EMAIL_PORT = 587, 25, 465 
EMAIL_HOST_USER = 'noreply@mydomain.com'
EMAIL_HOST_PASSWORD = '16CharacterAppPassword', 'mynormalpassword'

Other things I have tried:我尝试过的其他事情:

LessSecure settings: On/Off
App Password: Tried 2 two different ones just incase the first one messed up
Contact G-Suite support: They had a look at the settings and everything is fine from their end
Tried CaptchaLink
Tried verifying last login attempt as 'it was me' so it won't block the IP

Tried the following tutorial: G-Suite Smtp尝试了以下教程: G-Suite Smtp

More details if it might help:如果可能有帮助,请提供更多详细信息:

Server: Pythonanywhere
Domain: Google registered domain

Python: 3.8
Django: 3.1.1
django-allauth: 0.42.0

Error msg I get when trying to send an email:尝试发送电子邮件时收到错误消息:

SMTPAuthenticationError: Username and Password not accepted learn more at ...

Followed the link provided and tried all the trouble shoot methods.按照提供的链接尝试所有故障排除方法。

EDIT: After 48hrs it's randomly working and nothing has really changed in terms of what I have tried.编辑: 48 小时后,它随机工作,就我尝试过的而言,没有任何真正改变。 I'll leave this open if someone knows what the cause might have been?如果有人知道原因可能是什么,我会保持开放状态? Only thing I can think of is DNS Propagation but can't confirm since support mentioned that everything was fine their side.我唯一能想到的是 DNS 传播,但无法确认,因为支持人员提到一切都很好。

maybe the SITE_ID is wrong try to enter to the shell and get the right SITE_ID by this command:也许 SITE_ID 是错误的,尝试进入 shell 并通过以下命令获取正确的 SITE_ID:

 from django.contrib.sites.models import Site

    new_site = Site.objects.create(domain='....', name='....')

    print new_site.id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM