我正在尝试使Rails 5.2邮件程序正常工作,但在Heroku环境和我的环境中Net::SMTPAuthenticationError - 535 Authentication failed: account disabled
均遇到错误。localhost
production
邮件程序看起来像这样:
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 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
(在localhost和生产环境中正确)仔细检查了我的用户名和密码。
我的内容如下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
}
我被正式困住了。谁能看到为什么发生此错误?
你设置中的所有内容看起来都是正确的,所以这不只是简单
Net::SMTPAuthenticationError - 535 Authentication failed: account disabled
你的帐户出于任何原因disabled
。与Sendgrid确认你的帐户已启动并正常运行。
由于某种原因,我不得不删除并重新配置插件...但是由于我的帐户已被标记为红色,因此一开始我不允许重新添加它。我联系了支持人员,他们说这显然是“假阳性”情况,对不起,并重新激活了我的帐户。太奇怪了,但是现在可以使用了!
这是正确的,@ Liz在大多数情况下,当一个帐户处于休眠状态时,都会用红色标记它。