Ruby on rails error error 535-5.7.1 Username and password are not accepted

I get an error when trying to send an email. I am trying to send email with localhost .. setting actionmailer

ActionMailer::Base.smtp_settings = { :enable_starttls_auto => true, :address => "smtp.gmail.com", :port => 587, :domain => "mydomain.com", :authentication => :plain, :user_name => " do-not-reply@mydomain.com ", :password => "mypassword" } 

When I set it up for the first time, the mail worked fine. but after sending 4 or 5 letters, the function stopped working and will show me this error.

Net :: SMTPAuthenticationError ............

535-5.7.1 Username and password are not accepted.

Where could the problem be?

Thanks..

+6
source share
4 answers

I tried to send smtp from a ruby โ€‹โ€‹application on my hosted web server, and I was denied that something Gmail was taking precautions.

The solution was the first to log into gmail in my browser on my laptop, as usual. A warning appears at the top of the screen that gmail has detected suspicious activity. "It was you?" I pressed a few steps, saying that it was me, and was delivered to the screen, which said:

The next step

Log in using the application you want to allow access to yours for the next ten minutes. Google will remember the application after signing it and allow it to access your future if it uses the correct password.

Then I ssh'd to my server and from the command line did:

 lynx http://mail.google.com/mail/?ui=html 

Then I logged into gmail using lynx and the problem was resolved.

+2
source

I had the same problem, and when I double-checked the password, I realized that I typed it incorrectly.

Thus, the error could be caused by an incorrect password and probably an incorrect username. After you correct the username and password, make sure you restart the rails application.

I also assume that you are not actually using the literal text "mydomain.com", right?

0
source

If you are sure that you have repeatedly checked your settings and still get:

 535-5.7.8 Username and Password not accepted 

Try restarting the rail server, especially when you have changed the yaml file or the environment files.

 rails s 

See When do I need to restart a server in Rails? , for more information on when and why you should restart.

0
source

Go to config/initializers/setup_mail.rb Check if the configuration matches the configuration written in the development.rb file. Both files should look like this:

 config.action_mailer.smtp_settings = { :address =>" smtp.gmabirdvision17@gmail.comil.com ", :port => 587, :domain => "gmail.com", :user_name => " mygmail@gmail.com ", :password => "**********", :authentication => 'plain', :enable_starttls_auto => true, :openssl_verify_mode => 'none' } 

This will definitely solve your problem.

0
source

Source: https://habr.com/ru/post/909884/


All Articles