SendGrid on Heroku fails

RoR + SendGrid + Heroku:

I came across similar problem where I kept receiving this error Net::SMTPAuthenticationError (535 Authentication failed: Bad username / password when I was trying to send email.

I tried

  • username with which I signed up with sendgrid, and
  • also the one heroku generated (when I commissioned the addon).

Answer is very simple.

DO not use any username. It is simple text 'apikey' and for password use the generated API key that you got from Dashboard.

More here # https://support.sendgrid.com/hc/en-us

What is my SMTP Username and Password?

We recommend using "apikey" for your SMTP username and creating an API Key to use for your password. For more information, click here. https://sendgrid.com/docs/for-developers/sending-email/integrating-with-the-smtp-api/


I had tried to set my password with the command:

heroku config:add SENDGRID_PASSWORD=my-new-password

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.