G Suite and Django for SMTP

大兔子大兔子 提交于 2020-03-18 06:27:30

问题


I'm in the process of getting G Suite to work with my django site so that it will replace the SMTP server of my host. I configured my domain within my webhost's config panel. As a result, when I send an email to support@mysite.com, I can see that it successfully comes though to the Google Account, which is great.

My application is setup to send out a confirmation email after someone tries to register.

I've completed what I believe to be all of the required steps to setup G Suite with my django project, but I still get an error when my project attempts to send out the confirmation email after someone registers. Specifically, I'm seeing the following on the Django error page:

SMTPServerDisconnected at /access/register/ Connection unexpectedly closed

I've completed the following steps:

1.I've setup the SMTP relay service (https://support.google.com/a/answer/2956491), which means I've:

  • turned on comprehensive mail storage as per the instructions
  • added the SMTP relay service setting
  • allowed less secure apps (https://myaccount.google.com/lesssecureapps) in my settings

2.In my django settings files, I'm using the following settings:

EMAIL_HOST = 'smtp-relay.gmail.com'
EMAIL_HOST_USER = 'support@mysite.com'
EMAIL_HOST_PASSWORD = '********'
DEFAULT_FROM_EMAIL = 'support@mysite.com'
SERVER_EMAIL = 'support@mysite.com'
EMAIL_PORT = 465 
EMAIL_USE_TLS = False

I should also mention that with the following settings, my app was able to send out validation emails following registration with the webhost's SMTP server before I started down the path of implementing G Suite, so that I know that that part of the app works.

EMAIL_HOST = 'smtp.mywebhost.com'
EMAIL_HOST_USER = 'admin'
EMAIL_HOST_PASSWORD = '*****'
DEFAULT_FROM_EMAIL = 'support@mysite.com'
SERVER_EMAIL = 'support@mysite.com'
EMAIL_PORT = 25 
EMAIL_USE_TLS = False

I'm pretty certain I'm missing something on the G Suite configuration side and I was hoping that you could help.

Thanks!


回答1:


Accoding to the documentation of GSuite here : https://support.google.com/a/answer/2956491

If you are using "EMAIL_USE_TLS=False" then you will have to use some other authentication for the SMTP server like "IP Address Authentication".

If you do not setup the IP address filter in GSuite settings, your connection will the "unexpectedly closed".

Please try the point no 8 in the help page link above.



来源:https://stackoverflow.com/questions/49472897/g-suite-and-django-for-smtp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!