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

10,589

Solution 1

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

Solution 2

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.

Share:
10,589
pigate
Author by

pigate

Updated on June 04, 2022

Comments

  • pigate
    pigate almost 2 years

    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.

  • pigate
    pigate over 9 years
    Yeah I've done it already :( Thanks though for the suggestion
  • swapyonubuntu
    swapyonubuntu almost 9 years
    1000$ answer. Finally , after 100 attempts I came to know that this silly reason had wasted my 2 weeks.Thanks a ton !!
  • 0112
    0112 about 8 years
    @pigate if you've done it already, why did you mark it as the answer?
  • ZX12R
    ZX12R almost 8 years
    Thanks you so much. I started seriously doubting my debugging skills since no effort I was making solved this error.
  • Kelsey Hannan
    Kelsey Hannan over 6 years
    Is there a way of solving this that doesn't involving making my app less secure?