Ruby on Rails: bad username / password? (Error 535 Auth)

I just finished my coursework for rubies in the block and I'm starting to bury my head in the development of the rails. Things went smoothly until I hit that snag with e-mails and confirmation. I tried googling and looked at some other questions, but couldn't find anything that would give me anything that I could pull off and apply to my situation.

When registering for an account, the following error appears.

Net :: SMTPAuthenticationError in Devise :: RegistrationsController # create

535 Authentication error: invalid username / password


Error retrieved from source around line # 976

def check_auth_response(res)
  unless res.success?
    raise SMTPAuthenticationError, res.message
  end
end

      


From other posts I know, you probably want to see that I have a config / initializers / setup_mail.rb file that looks like this:

if Rails.env.development?
  ActionMailer::Base.delivery_method = :smtp
  ActionMailer::Base.smtp_settings = {
    address:        'smtp.sendgrid.net',
    port:           '587',
    authentication: :plain,
    user_name:      ENV['SENDGRID_USERNAME'],
    password:       ENV['SENDGRID_PASSWORD'],
    domain:         'heroku.com',
    enable_starttls_auto: true
  }
end

      


And here is the application.yml file EXAMPLE:

SENDGRID_PASSWORD: 
SENDGRID_USERNAME:
SECRET_KEY_BASE:

      


Also, I have the following in my config / environment / development.rb:

config.action_mailer.default_url_options = { host: 'localhost:3000'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
# Override Action Mailer 'silent errors' in development
config.action_mailer.raise_delivery_errors = true

      


If there are any other files you would like to see, let me know and I will add them to this post.

+3


source to share


1 answer


Congratulations and cheers to the world of hacking on cool stuff.

The error received means the SendGrid server received a bad username and password.

Most likely your environment variables are empty and your file is application.yml

not loading properly with your SendGrid username and password.

You can confirm this by printing them out somewhere in your code. The controller works.



puts "SENDGRID_USERNAME: #{ENV['SENDGRID_USERNAME']}"
puts "SENDGRID_PASSWORD: #{ENV['SENDGRID_PASSWORD']}"

      

I suspect they are zero.

I would recommend reading https://quickleft.com/blog/simple-rails-app-configuration-settings/ on how to get them into your application.

Please let me know if you need more help!

+7


source







All Articles