Search code examples
ruby-on-railsrubydeviseapartment-gem

Mailer in Ruby on Rails


I am migrating an ROR3 application to ROR4. And I am very new to this and I am learning along with the migration. I got stuck in the first step it self I am getting an error

Net::SMTPAuthenticationError in ClientsController#create
534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbtq6

Here is my configuration in development.rb.

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

  ActionMailer::Base.smtp_settings = {
          :address              => "smtp.gmail.com",
          :port                 => 587,
          :domain               => "gmail.com",
          :user_name            => Rails.application.secrets.email_address,
          :password             => Rails.application.secrets.email_password,
          :authentication       => "plain",
          :enable_starttls_auto => true }

The place where I am getting the error is at

@client.save.

 Apartment::Tenant.create(@client.subdomain)
      Apartment::Tenant.switch(@client.subdomain)
      @client.save
      redirect_to new_user_session_url(subdomain: @client.subdomain)
    else
      render action: 'new'

Can anyone help who is working on ROR?


Solution

  • I had this same issue, be sure to take a look at your gmail account security settings and enable "Access for less secure apps" from www.google.com/settings/security."