Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 735
pigate Avatar asked Nov 15 '14 01:11

pigate


2 Answers

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

like image 97
Sibevin Wang Avatar answered Nov 06 '22 15:11

Sibevin Wang


This solution works fine for me.

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: [email protected],
    password: mypassword,
    authentication: 'plain',
    enable_starttls_auto: true
}

As google will try to block your sign-in if you have turned off access for less secure apps in your accounts settings. Therefore, follow this link and "Turn on" access for less secure apps.

like image 1
techdreams Avatar answered Nov 06 '22 14:11

techdreams