Search code examples
djangodjango-formsgmail

Strange behaviour with e-mails between Django and Google


I have configured my Django settings to send an e-mail using gmail (for password reset) However, I'm facing a strange behaviour from Google:

  • Locally, it works fine, when I use my Django app and I get the report that an email has been sent;
  • Deployed on DigitalOcean, using the shell, it works fine:
>>> from django.core.mail import send_mail
>>> send_mail("Objet3", "Message body", "[email protected]",['[email protected]'], fail_silently=False)
1

However, when using the deployed app, I always get a Server Error 500, which is reported as such by Sentry:

SMTPSenderRefused: (530, b'5.7.0 Authentication Required. Learn more at\n5.7.0  https://support.google.com/mail/?p=WantAuthError f6sm10267338edk.13 - gsmtp', 'webmaster@localhost')

It's really puzzling, as at Gmail:

  • I have decreased the level of security,
  • I have created an App pass and implemented it... Does anyone have an idea, where it may come from ?

Solution

  • Google does not want to be an email provider like this so they've made it increasingly difficult. Look into a provider such as sendgrid, mailgun, or others.