535-5.7.8 Username and Password not accepted

后端 未结 8 1809
逝去的感伤
逝去的感伤 2020-12-24 01:17

I have a contact form and after submitting I am getting a Net::SMTPAuthenticationError 535-5.7.8 Username and Password not accepted

It\'s pointing to th

相关标签:
8条回答
  • 2020-12-24 01:47

    Goto config/initializers/setup_mail.rb Check whether the configuration there matches the configuration written in the development.rb file.It should look like the following in both files:

    config.action_mailer.smtp_settings = {
         :address =>"smtp.gmabirdvision17@gmail.comil.com",
         :port => 587,
         :domain => "gmail.com",
         :user_name => "PPPPPPPP@gmail.com",
         :password => "********",
         :authentication => 'plain',
         :enable_starttls_auto => true,
         :openssl_verify_mode => 'none' 
         } 
    

    This will most certainly solve your problem.

    0 讨论(0)
  • 2020-12-24 01:52

    First, You need to use a valid Gmail account with your credentials.

    Second, In my app I don't use TLS auto, try without this line:

    config.action_mailer.smtp_settings = {
      address:              'smtp.gmail.com',
      port:                 587,
      domain:               'gmail.com',
      user_name:            'YOUR_USERNAME@gmail.com',
      password:             'YOUR_PASSWORD',
      authentication:       'plain'
      # enable_starttls_auto: true
      # ^ ^ remove this option ^ ^
    }
    

    UPDATE: (See answer below for details) now you need to enable "less secure apps" on your Google Account

    https://myaccount.google.com/lesssecureapps?pli=1

    0 讨论(0)
  • 2020-12-24 01:55

    If you still cannot solve the problem after you turn on the less secure apps. The other possible reason which might cause this error is you are not using gmail account.

    -    : user_name  =>  'example@company.com' ,  # It can not be used since it is not a gmail address 
    +    : user_name  =>  'example@gmail.com' ,  # since it's a gmail address
    

    Refer to here.

    Also, bear in mind that it might take some times to enable the less secure apps. I have to do it several times (before it works, every time I access the link it will shows that it is off) and wait for a while until it really work.

    0 讨论(0)
  • 2020-12-24 02:02

    I had the same problem. Now its working fine after doing below changes.

    https://www.google.com/settings/security/lesssecureapps

    You should change the "Access for less secure apps" to Enabled (it was enabled, I changed to disabled and than back to enabled). After a while I could send email.

    0 讨论(0)
  • 2020-12-24 02:02

    In my case removing 2 factor authentication solves my problem.

    0 讨论(0)
  • 2020-12-24 02:05

    Time flies, the way I do without enabling less secured app is making a password for specific app

    Step one: enable 2FA

    • https://myaccount.google.com/signinoptions/two-step-verification/enroll-welcome

    Step two: create an app-specific password

    • https://myaccount.google.com/apppasswords

    After this, put the sixteen digits password to the settings and reload the app, enjoy!

      config.action_mailer.smtp_settings = {
        ...
        password: 'HERE', # <---
        authentication: 'plain',
        enable_starttls_auto: true
      }
    
    0 讨论(0)
提交回复
热议问题