Rails 5.2 Net::SMTPAuthenticationError - 535 身份验证失败:发送电子邮件时禁用帐户(Localhost 和 Heroku) [英] Rails 5.2 Net::SMTPAuthenticationError - 535 Authentication failed: account disabled When Sending Email (Localhost and Heroku)

查看:67
本文介绍了Rails 5.2 Net::SMTPAuthenticationError - 535 身份验证失败:发送电子邮件时禁用帐户(Localhost 和 Heroku)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让 Rails 5.2 邮件程序正常工作,但遇到 Net::SMTPAuthenticationError - 535 Authentication failed: account disabledlocalhost 和我的 Heroku 生产 环境.

I'm trying to get a Rails 5.2 mailer working, but am coming across a Net::SMTPAuthenticationError - 535 Authentication failed: account disabled error on both localhost and my Heroku production environment.

邮件看起来像这样:

class AdminNotificationsMailer < ApplicationMailer
  default from: "liz@linchpinindustries.com"

  def new_rfp(rfp)
    @rfp = rfp
    mail(
      :to => "liz@linchpinindustries.com",
      :subject => 'New RFP Alert!'
    )
  end

  def new_contact_us(contact)
    @contact = contact
    mail(
      to: "liz@linchpinindustries.com",
      subject: 'New Contact Us Submission on LPI'
    )
  end

end

在我的 rfp#create 操作 中使用触发器(对于第一个邮件程序,new_rfp 一个):

With the trigger in my rfp#create action (for the first mailer, the new_rfp one):

def create
    @rfp = Rfp.new(rfp_params)

    respond_to do |format|
      if @rfp.save!
        AdminNotificationsMailer.new_rfp(@rfp).deliver
        format.html { redirect_to root_path, notice: "Thanks for your request!  We'll get back to you ASAP.  Stay tuned!" }
        format.json { render :show, status: :created, location: @rfp }
      else
        format.html { render :new }
        format.json { render json: @rfp.errors, status: :unprocessable_entity }
      end
    end
  end

我已经配置了 Sendgrid 并使用 puts 仔细检查了我的用户名和密码(它在本地主机和生产环境中是正确的).

I have provisioned Sendgrid and double checked my username and password with puts (it is correct on localhost and production).

我的 environment.rb 中有以下内容:

I have the following in my environment.rb:

ActionMailer::Base.smtp_settings = {
  :user_name => ENV["SENDGRID_USERNAME"],
  :password => ENV["SENDGRID_PASSWORD"],
  :domain => 'linchpinindustries.com',
  :address => 'smtp.sendgrid.net',
  :port => 587,
  :authentication => :plain,
  :enable_starttls_auto => true
}

我咨询过类似this这个,但没有任何效果.

I've consulted posts like this and this, but nothing is working.

我被正式难住了.谁能看出为什么会发生此错误?

I'm officially stumped. Can anyone see why this error is occurring?

推荐答案

您的设置中的所有内容看起来都正确,所以这不仅仅是

Everything in your settings looks correct so is this not just as simple as

Net::SMTPAuthenticationError - 535 Authentication failed: account disabled

您的帐户因任何原因禁用.与 Sendgrid 检查您的帐户是否已启动并正常运行.

your account is for whatever reason disabled. Check with Sendgrid that your account is up and running correctly.

这篇关于Rails 5.2 Net::SMTPAuthenticationError - 535 身份验证失败:发送电子邮件时禁用帐户(Localhost 和 Heroku)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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