I setup send grid starter for my heroku app.
I put this in my config/environment.rb:
ActionMailer::Base.smtp_settings = {
:user_name => ENV["SENDGRID_USERNAME"],
:password => ENV["SENDGRID_PASSWORD"],
:domain => "my-sites-domain.com",
:address => "smtp.sendgrid.net",
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
I create this class models/notifier.rb:
class Notifier < ActionMailer::Base
def notify()
mail(
:to => "my-email@gmail.com",
:subject => "New Website Contact",
:body => "body",
:message => "message",
:from => "website@my-sites-domain.com"
)
end
end
I put this in another controller to send the email:
def contact
Notifier.notify().deliver
redirect_to("/", :notice => "We Have Received Your Request And Will Contact You Soon.")
end
When I deploy and try to send an email I get this error:
Net::SMTPAuthenticationError (535 Authentication failed: Bad username / password
I have setup send grid completely and it says I am ready to send emails.
I also ran heroku config --long to get the actual password and user name and hard coded them and that still gave me the same error.
I had tried to set my password with the command:
But it turns out this only changes what heroku has stored as your password, it doesn’t actually change your password. You also cannot retrieve your password after doing this.
What I had to do was remove and re-add the sendgrid add on.