ruby-on-railsherokudevisesendgridrailsapps

Heroku Sendgrid not sending and not showing errors?


I am trying to get "Devise Confirmable" email confirmations to work through Sendgrid on Heroku running Rails 4.2

I set up the rails-devise-pundit starter app with Devise Confirmable & Sendgrid options.

Running on Ubuntu 14.04 in development I just needed to set the SENDGRID_USERNAME and SENDGRID_PASSWORD environment variables and everything works perfectly in development. Signing up sends an email and clicking the link in my inbox redirects me to the app running on my local machine and signs me up as expected.

I deploy the exact same app to Heroku, here I set 3 environment variables using heroku config SENDGRID_DOMAIN (the url of my heroku app)

SENDGRID_PASSWORD (private)

SENDGRID_USERNAME (private)

I get the same flash saying that the "confirmation link has been sent".

heroku log reveals Devise::Mailer#confirmation_instructions: processed outbound mail in 461.2ms

Everything seems to go perfect, except that when the app is running on Heroku the email never arrives, but when running on my dev machine it does.

Switched to Mandrill and reproduced the exact same scenario using Mandrill.

I don't see any error message anywhere and can't see any other issues when scrolling over the logs, how do I go about solving this?


Solution

  • I have not found any error messages to help point to this but the problem was with the DOMAIN_NAME environment variable that was set on Heroku.

    I accidentally included https:// before the domain name, so my heroku config revealed DOMAIN_NAME: https://example.com. After removing the https:// and setting the environment variable to just example.com the problem goes away when using Sendgrid or Mandrill and the confirmation emails works as expected.