我正在尝试使Rails 5.2的邮件发送器工作,但在
邮件发送器的代码如下:
localhost
和我的Heroku production
环境中都遇到了Net::SMTPAuthenticationError - 535 Authentication failed: account disabled
错误。邮件发送器的代码如下:
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
进行了用户名和密码的双重检查(在本地主机和生产环境中都是正确的)。
我在我的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
}
现在我被难住了。有谁能看出这个错误发生的原因吗?