【发布时间】:2020-03-17 22:51:56
【问题描述】:
目标
- 在使用 Django 3 构建的 Digital Ocean 上部署登录页面。
- 将我的 G Suite 帐户添加到联系表单中,以便人们可以输入他们的电子邮件、主题、消息并将其发送给我。
我做了什么
- 我通过以下guide 建立了我的联系方式。
- 我已经对其进行了测试,它会按原样打印出终端中的所有参数
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: helllo
From: customeremail@gmail.com
To: admin@example.com
Date: Tue, 17 Mar 2020 14:29:40 -0000
Message-ID: <12121212121212.1222212121212.1212121212121212@mymachinename.local>
This is the message.
- 完成教程后,我已将以下内容添加/切换到 settings.py 文件中
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp-relay.gmail.com'
EMAIL_HOST_USER = 'mayname@mycompanydomain.com'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
- 我购买了 G Suite 订阅,其中包含 G Suite SMTP 中继服务,每天可以发送 10000 封电子邮件。
错误
1.第一次运行后我收到以下邮件:
Sign-in attempt was blocked
myname@businessemaildomainname.com
Someone just used your password to try to sign in to your account from a non-Google app. Google blocked them, but you should check what happened. Review your account activity to make sure no one else has access.
Check activity
2.第二次运行后,我在浏览器中收到以下错误消息(没有电子邮件)
SMTPAuthenticationError at /email/
(535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials 121sdgsdf.12 - gsmtp')
Request Method: POST
Request URL: http://127.0.0.1:8000/email/
Django Version: 3.0
Exception Type: SMTPAuthenticationError
3.在寻求谷歌帮助聊天并切换了一堆设置而不是再次运行相同的代码后
SMTPSenderRefused at /email/
(111, b"5.7.0 Mail relay denied [1111:1a1a:111a:1111:1aaa:aaa:a11aa:aa11a].
Invalid\n5.7.0 credentials for relay for one of the domains in:
myusername.local,\n5.7.0 mydomainname.com (as obtained from HELO and MAIL FROM).\n5.7.0
Email is being sent from a domain or IP address which isn't registered\n5.7.0
in your G Suite account. Please login to your G Suite account and\n5.7.0
verify that your sending device IP address has been registered within\n5.7.0
the G Suite SMTP Relay Settings. For more information, please visit\n5.7.0
https://support.google.com/a/answer/6140680#maildenied 1aa1a1a1a1k.111 - gsmtp", 'thecontactfillercustomeremail@gmail.com')
【问题讨论】:
标签: python django email digital-ocean google-workspace