Search code examples
ruby-on-railsemailauthenticationsend

resend confirmation mail error Net::SMTPAuthenticationError in Devise::ConfirmationsController#create


Net::SMTPAuthenticationError in Devise::ConfirmationsController#create

530-5.5.1 Authentication Required. Learn more at

I am using the gem 'devise'.

to send confirmation email with gmail account.

but, the error in title occur.

I searched many cases similar to my case and tried solutions in there, but those perfectly not worked, so I think my error has some different origin

( what I tried is : 1. less securing myaccount.google.com/u/1/security 2. http://www.google.com/accounts/DisplayUnlockCaptcha)

development.rb

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.smtp_settings = {
    :authentication => :plain,
    :address => "smtp.gmail.com",
    :port => 587,
    :domain => "mail.google.com",
    :user_name => ENV["******@gmail.com"],
    :password => ENV["******"],
    :enable_starttls_auto => true
  }

  config.action_mailer.default_url_options = {:host => 'localhost:3000'}

top most error line in error page

def check_response(res)
  unless res.success?
    raise res.exception_class, res.message
  end
end

please help me... TT


Solution

  • the problem your gmail setting, you should remove the ENV as you put string directly to it (as my understanding this is your local development this will generate an error since you also put config.action_mailer.raise_delivery_errors = true

      config.action_mailer.smtp_settings = {
        :authentication => :plain,
        :address => "smtp.gmail.com",
        :port => 587,
        :domain => "mail.google.com",
        :user_name => "******@gmail.com",
        :password => "******",
        :enable_starttls_auto => true
      }