Question

Unable to send mail through smtp.gmail.com

I have recently become unable to send any e-mail from my Django app hosted on a DO droplet through smtp.gmail.com. Any time I try, I get the following error message:

SMTPAuthenticationError (535, ‘5.7.8 Username and Password not accepted. Learn more at\n5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 sh5sm32272477pbc.21 - gsmtp’)

Which is weird, because the username and password used works perfectly when I try to log in manually, or when sending through the exact same Django app from localhost.

I have also tried going through http://www.google.com/accounts/DisplayUnlockCaptcha , as mentioned in the Google support answer.

I have been sending at maximum a couple of hundred e-mail in total from that account, with maybe ~10 a day - so abuse seems to be out of the question for me. I should mention that the account is a paid Google Apps account.

The fact that I can use the exact same settings while using localhost as a server, plus the fact that this error has only appeared recently, makes me think that the error might have something to do with Digital Ocean.

Do you have any ideas about what might cause this?

Thanks and with the best regards, Martin

Ps. for good measure, here are my smtp settings, minus the password (which I am 100% sure is correct):

EMAIL_USE_TLS = True EMAIL_HOST = ‘smtp.gmail.com’ EMAIL_PORT = 587 EMAIL_HOST_USER = ‘info@CoCreately.com’ EMAIL_HOST_PASSWORD = <redacted>

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hey guys, just found what’s going on with those errors.

The problem is that when you have activated the Google Authenticator Verification you also need to set up the 2-Step-Authentication in your gmail account.

Therefore visit https://www.google.com/settings/security - when you have done so, just go back to this page and click the “App Password” - Settings.

Select “Other (custom name)” and enter any name you like. Go ahead and copy the code and paste it to your projects settings.

Done! - This resolved all issues for me.

Greets P4rks!

  1. Go to admin.google.com
  2. From the admin console, select “Security”
  3. Select “Basic settings”
  4. Scroll down to “Less secure apps”
  5. Go to settings for less secure apps ››
  6. Check the radio button “Allow users to manage their access to less secure apps”
  7. Save the changes
  8. Open this link being sign in as the super administrator https://www.google.com/settings/security/lesssecureapps
  9. Check the radio button Turn On the access for less secure apps
  10. Unlock Captcha using this link https://accounts.google.com/DisplayUnlockCaptcha

I had the same problem. I guess it’s a gmail ban, because the Gmail send a mail with this link: https://support.google.com/mail/answer/14257?p=client_login&rd=1

The point is this: https://www.google.com/settings/security/lesssecureapps

You should change the “Access for less secure apps” to Enabled (it was enabled, I changed to disabled and than back to enabled). After a while I could send email.