Django 3,G Suite的联系表格-电子邮件发送错误



目标

  • 在Django 3构建的Digital Ocean上部署登录页
  • 将我的G套件帐户添加到联系人表单中,这样人们就可以键入他们的电子邮件、主题和消息并将其发送给我

我做了什么

  • 我根据以下指南建立了联系
  • 我已经测试过了,它会打印出终端中的所有参数
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中继服务,每天可以发送10’000封电子邮件

错误

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 atn5.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]. 
Invalidn5.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 registeredn5.7.0 
in your G Suite account. Please login to your G Suite account andn5.7.0 
verify that your sending device IP address has been registered withinn5.7.0 
the G Suite SMTP Relay Settings. For more information, please visitn5.7.0
https://support.google.com/a/answer/6140680#maildenied 1aa1a1a1a1k.111 - gsmtp", 'thecontactfillercustomeremail@gmail.com')

G-mail的问题,即使你在一段时间后让它工作,谷歌也会在它最痛苦的时候删除它。更好的解决方案是使用以下一些解决方案

  • sendgrid.com
  • mailjet.com
  • icontact.com
  • mailgun.com

最新更新