Rails 4 ActionMailer with gmail Net::SMTPAuthenticationError: 534-5.7.14

pigate picture pigate · Nov 15, 2014 · Viewed 10.3k times · Source

I am trying to send an email in development version of my app. Nothing I am doing is working. I keep getting hit with: Net::SMTPAuthenticationError: 534-5.7.14 https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=blahblahblah

Other SO posts I have followed:

Net::SMTPAuthenticationError when sending email from Rails app (on staging environment)

Running into SMTP error when trying to send email in RoR app

... etc... and nothing works. I'm going to tear my brains out if can't be resolved. I have spent so long on this...

I have tried going directly to http://www.google.com/accounts/DisplayUnlockCaptcha and click continue, no results. I have already in my google account settings enabled less secure apps access(Google -> Security -> Account permissions -> Access). I have tried going to the link posted after the error, and logged in from there, and no results.

My setup in config/environments/development.rb

  config.action_mailer.default :charset => "utf-8"
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address: 'smtp.gmail.com',
    port: 587,
    domain: 'mysite.com',
    user_name: ENV['MAIL_EMAIL'],
    password: ENV['MAIL_PASS'],
    authentication: 'plain',
    enable_starttls_auto: true
  }

If this makes any difference:

From the apache error logs:

Warning: Name-based SSL virtual hosts only work for clients with TLS server name indication support

I am hosting two domains on the same IP address.

I switched my rails app to production mode, to see if it would help. No results.

Please help.

Answer

Sibevin Wang picture Sibevin Wang · Nov 15, 2014

Go to your Google Account settings, find Security -> Account permissions -> Access for less secure apps, enable this option.

About this option: https://support.google.com/accounts/answer/6010255