Question
Unable to send mail through smtp.gmail.com
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.
×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.
×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!
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”,
clientId:“clientId”,
clientSecret:“clientSecret”,
refreshToken:“refreshToken”
}
}
Your speedy assistance is appreciated.
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/init.py”, line 61, in sendmail
return mail.send()
File “/usr/local/lib/python3.5/site-packages/django/core/mail/message.py”, line 292, in send
return self.getconnection(failsilently).sendmessages([self])
File “/usr/local/lib/python3.5/site-packages/django/core/mail/backends/smtp.py”, line 100, in sendmessages
newconncreated = self.open()
File “/usr/local/lib/python3.5/site-packages/django/core/mail/backends/smtp.py”, line 58, in open
self.connection = connectionclass(self.host, self.port, connectionparams)
File “/usr/local/lib/python3.5/smtplib.py”, line 251, in _init__
(code, msg) = self.connect(host, port)
File “/usr/local/lib/python3.5/smtplib.py”, line 335, in connect
self.sock = self.getsocket(host, port, self.timeout)
File “/usr/local/lib/python3.5/smtplib.py”, line 306, in getsocket
self.sourceaddress)
File “/usr/local/lib/python3.5/socket.py”, line 712, in createconnection
raise err
File “/usr/local/lib/python3.5/socket.py”, line 703, in create_connection
sock.connect(sa)
**OSError: [Errno 99] Cannot assign requested address
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.
Woo! I spent a good half hour beating my head into a wall trying to figure this out, but this step solved it for me. Thanks!
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 http://support.google.com/mail/bin/answer.py?answer=14257 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.
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:
https://www.google.com/settings/security/lesssecureapps
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 https://myaccount.google.com/apppasswords
I found out my Google password had special characters, which led to the /etc/postfix/sasl_passwd not being properly read. Simply the password (long one ofc) with up/lower case characters, numbers.
I also combined the settings found here if you still have trouble:
https://opentodo.net/2013/03/postfix-smtp-relay-to-smtp-gmail-com/
see:
https://github.com/andris9/Nodemailer/issues/192 and search for user: aco7342
HI P4rs,
I have the same problem. I fallowed your instructions. This works good on my local host. But when i use same on my live it give me error “535 Incorrect authentication data”. I believe that it is due to location of my live server. But what will be the solution for this?
Thanks in advance,
We are experiencing the same issue. We can be sure that the Gmail server settings and code is correct, as our production server (on different infrastructure, same domain) works fine and is currently sending emails. Only our development server which is hosted on Digital Ocean fails to send emails and gets the same message listed above.
Is it possible that the Digital Ocean subnet has been blacklisted by Gmail?
Any resolution for this issue?. Two of my earlier deployments work fine, but the newest one is giving this issue. Can’t find a resolution
Same issue with my droplet. Anyone can help?
encountered the same issue. But solved after generating a new app password for Digital Ocean server from here https://security.google.com/settings/security/apppasswords and using it.
any update abount this error, i mean, at cakephp -> EmailTransport same description, but i have this error.
SMTP server did not accept the password. Cake\Network\Exception\SocketException
@omarg55 you need to turn on “Access for less secure apps” on the gmail account you are trying yo use
@cartocri it is ready “Access for less secure apps”, but again warming SMTP server did not accept the password.
‘EmailTransport’ => [
'default’ => [
'className’ => 'Smtp’,
// The following keys are used in SMTP transports
'host’ => 'ssl://smtp.gmail.com’,
'port’ => 465,
'timeout’ => 30,
'username’ => ’xxx@gmail.com’,
'password’ => 'xxx’,
//'client’ => null,
//'tls’ => true,
Google now doesn’t accept login from less secure apps. So you need to go to https://myaccount.google.com/security scroll to the bottom and turn ON “Allow less secure apps: ON”. Now when you add the SMTP details to “Send as” google will accept them. You need to do this for the email ID you are adding in your Send as section.
Hi,
Firstly you should activate two factor authentication on your gmail account and should change the “Access for less secure apps” to Enabled at This Link after that must set a application password for your application via using This Link then it will work