535-5.7.8 不接受用户名和密码 [英] 535-5.7.8 Username and Password not accepted

查看:75
本文介绍了535-5.7.8 不接受用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个联系表格,提交后我收到 Net::SMTPAuthenticationError 535-5.7.8 用户名和密码不被接受

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

它指向联系人控制器中的创建操作ContactMailer.new_contact(@contact).deliver

It's pointing to the create action in the contacts controller ContactMailer.new_contact(@contact).deliver

我已经重新启动了服务器.我尝试了 https://accounts.google.com/DisplayUnlockCaptcha.

I have restarted the server. I tried https://accounts.google.com/DisplayUnlockCaptcha.

我正在开发中.

联系人控制器:

 def new
      @contact = Contact.new
    end

    def create
      @contact = Contact.new(params[:message])
      if @contact.valid?
        ContactMailer.new_contact(@contact).deliver
        flash[:notice] = "Message sent! Thank you for contacting us."
        redirect_to root_url
      else
        render :action => 'new'
      end
    end
  end

Development.rb:

Development.rb:

  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address:              'smtp.gmail.com',
    port:                 587,
    domain:               'gmail.com',
    user_name:            'username@gmail.com',
    password:             'password',
    authentication:       'plain',
    enable_starttls_auto: true  }

  config.action_mailer.default_url_options = { :host => "localhost:3000" }

推荐答案

首先,您需要使用具有凭据的有效 Gmail 帐户.

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

其次,在我的应用中,我不使用 TLS auto,请尝试不使用此行:

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 ^ ^
}

<小时>

更新:(详情参见下面的答案)现在您需要在您的 Google 帐户中启用安全性较低的应用"


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

这篇关于535-5.7.8 不接受用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆