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.
The mailer looks like this:
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
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
I have provisioned Sendgrid and double checked my username and password with puts
(it is correct on localhost and production).
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
}
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
your account is for whatever reason disabled
. Check with Sendgrid that your account is up and running correctly.
For some reason I had to delete and reprovision the addon...but I wasn't allowed to re-add it at first because my account had been red flagged. I contacted support and they said it was clearly a "false positive" situation, apologized, and reactivated my account. So bizarre, but it works now!
This is correct, @Liz most of the time when an account is sleeping for a while, the red flag it.