I have a contact form and after submitting I am getting a Net::SMTPAuthenticationError 535-5.7.8 Username and Password not accepted
It\'s pointing to th
Goto config/initializers/setup_mail.rb
Check whether the configuration there matches the configuration written in the development.rb
file.It should look like the following in both files:
config.action_mailer.smtp_settings = {
:address =>"smtp.gmabirdvision17@gmail.comil.com",
:port => 587,
:domain => "gmail.com",
:user_name => "PPPPPPPP@gmail.com",
:password => "********",
:authentication => 'plain',
:enable_starttls_auto => true,
:openssl_verify_mode => 'none'
}
This will most certainly solve your problem.
First, You need to use a valid Gmail account with your credentials.
Second, In my app I don't use TLS auto, try without this line:
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: 'YOUR_USERNAME@gmail.com',
password: 'YOUR_PASSWORD',
authentication: 'plain'
# enable_starttls_auto: true
# ^ ^ remove this option ^ ^
}
UPDATE: (See answer below for details) now you need to enable "less secure apps" on your Google Account
https://myaccount.google.com/lesssecureapps?pli=1
If you still cannot solve the problem after you turn on the less secure apps
.
The other possible reason which might cause this error is you are not using gmail account.
- : user_name => 'example@company.com' , # It can not be used since it is not a gmail address
+ : user_name => 'example@gmail.com' , # since it's a gmail address
Refer to here.
Also, bear in mind that it might take some times to enable the less secure apps
. I have to do it several times (before it works, every time I access the link it will shows that it is off
) and wait for a while until it really work.
I had the same problem. Now its working fine after doing below changes.
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.
In my case removing 2 factor authentication solves my problem.
Time flies, the way I do without enabling less secured app
is making a password for specific app
Step one: enable 2FA
Step two: create an app-specific password
After this, put the sixteen digits password to the settings and reload the app, enjoy!
config.action_mailer.smtp_settings = {
...
password: 'HERE', # <---
authentication: 'plain',
enable_starttls_auto: true
}