Unable to send mail through

Posted March 10, 2014 383.8k views
I have recently become unable to send any e-mail from my Django app hosted on a DO droplet through 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 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 , 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 = '' EMAIL_PORT = 587 EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD =

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.

Submit an Answer
19 answers

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 - 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!

  • Worked like a charm!

    Thank you very much!

  • Hi,

    I tried your solution but I am still getting this error,

    code: “EAUTH”, response: “535-5.7.8 Username and Password not accepted.

    nodemailer createTransport() method works for me only when I use my email id and password, which is I think not a good choice.

    Instead I want to use auth : {
    XOAuth2: {
    user:"email id”,

    Your speedy assistance is appreciated.

  1. Go to
  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
  9. Check the radio button Turn On the access for less secure apps
  10. Unlock Captcha using this link

I have everything settled up with Gmail, but sending inside Droplet (inside docker) I got:

Traceback (most recent call last):
File “<console>”, line 1, in <module>
File “/usr/local/lib/python3.5/site-packages/django/core/mail/”, line 61, in sendmail
return mail.send()
File “/usr/local/lib/python3.5/site-packages/django/core/mail/”, line 292, in send
return self.get
File “/usr/local/lib/python3.5/site-packages/django/core/mail/backends/”, line 100, in sendmessages
conncreated =
File “/usr/local/lib/python3.5/site-packages/django/core/mail/backends/”, line 58, in open
self.connection = connection
class(, self.port, connectionparams)
File “/usr/local/lib/python3.5/”, line 251, in _
(code, msg) = self.connect(host, port)
File “/usr/local/lib/python3.5/”, line 335, in connect
self.sock = self.getsocket(host, port, self.timeout)
File “/usr/local/lib/python3.5/”, line 306, in getsocket
File “/usr/local/lib/python3.5/”, line 712, in create
raise err
File “/usr/local/lib/python3.5/”, line 703, in create_connection
**OSError: [Errno 99] Cannot assign requested address

I believe gmail limits the amount of emails you can send per day. You probably passed that limit. I recommend using a transactional mail service such as Mandrill or SendGrid.
I have the same issue running CakePHP, and completely sure that it's not a GMAIL ban, because i have the exactly same app running in another server and it is still sending emails... : (

I had the same problem. I guess it’s a gmail ban, because the Gmail send a mail with this link:

The point is this:

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.

I too ran into this problem today. I confirmed through my /var/log/mail.log that the connection happens, the username and password are sent (correct credentials), but the response is always:

535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 u8sm6322553qat.27 - gsmtp

I tried with an account that is in use in a different environment as well as with a brand new account within my google apps domain. Neither account worked.

For me the problem was not auth but the mail with valid URL inside.
I removed the urls and everything is fine.

There’s some changes from google security on Google Apps or gmail accounts.

To avoid the issue i had solved with the following steps:

1.Login into your account Gmail or Google Apps then goto:

and Turns On the Access for less secure apps.

You can have also this issue if you use Two Factor Sign-In. If so, you need to create a separate access to use for applications. you can manage them under

Previous 1 2 Next