Rails 5.2 Net :: SMTPAuthenticationError-535身份验证失败:发送电子邮件时帐户被禁用(Localhost和Heroku)

问题描述 投票:0回答:1

我正在尝试使Rails 5.2邮件程序正常工作,但是在Net::SMTPAuthenticationError - 535 Authentication failed: account disabled和我的Heroku localhost环境上都遇到了production错误。

邮件看起来像这样:

class AdminNotificationsMailer < ApplicationMailer
  default from: "[email protected]"

  def new_rfp(rfp)
    @rfp = rfp
    mail(
      :to => "[email protected]",
      :subject => 'New RFP Alert!'
    )
  end

  def new_contact_us(contact)
    @contact = contact
    mail(
      to: "[email protected]",
      subject: 'New Contact Us Submission on LPI'
    )
  end

end

在我的rfp#create action中带有触发器(对于第一个邮件,是new_rfp一个:]

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仔细检查了我的用户名和密码(在本地主机和生产环境中正确)。>>

我的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
}

我咨询过thisthis之类的帖子,但没有任何帮助。

我被正式困住了。谁能看到为什么发生此错误?

我正在尝试使Rails 5.2邮件程序正常工作,但是遇到了Net :: SMTPAuthenticationError-535身份验证失败:本地主机和Heroku生产环境都禁用了帐户错误...

ruby-on-rails sendgrid
1个回答
0
投票
您设置中的所有内容看起来都是正确的,所以这不只是简单的
© www.soinside.com 2019 - 2024. All rights reserved.