25

My site is hosted on Heroku and I installed the Sendgrid Add-On as it looked almost too good to be true - but so far none of the email functionality is working. I have read the documentation and it clearly says just add-the add on - is more configuration required to get Devise working?

When I select 'send me new password' I get a 404 page which makes me think there is more to this. Like how does Sendgrid know/where to use the pre-installed Devise templates?

Thx.

ubique
  • 1,212
  • 3
  • 17
  • 28
  • A 404 error is an error in your Devise routes. Verify your routes with `rake routes | grep devise`. Devise uses your ActionMailer. – Chloe Apr 16 '17 at 03:56

2 Answers2

52

I just set up Devise and SendGrid this morning and have no problems. I'm going to resume the steps I took.

First, install Devise and SendGrid. Congratulations, you've already done that ;)

Then, for production, add this to your files:

config/initializers/devise.rb :

config.mailer_sender = "mail-to-send@from.com"

Set up Rails ActionMailer to use SendGrid

config/environments/production.rb
config.action_mailer.default_url_options = { :host => 'your.websitedomain.com' }
ActionMailer::Base.smtp_settings = {
  :user_name            => ENV['SENDGRID_USERNAME'],
  :password             => ENV['SENDGRID_PASSWORD'],
  :address              => "smtp.sendgrid.net",
  :port                 => 587,
  :enable_starttls_auto => true,
  :authentication       => :plain,
  :domain               => "yourdomain.com"
}

And everything's working great with that. Sign up confirmations, password recovery...

Also, you should use Logging Expanded (it's Free!) and check your logs with heroku logs --tail (for real time). If you still get errors, post your logs.

Have a good day !

Community
  • 1
  • 1
Lucas
  • 2,886
  • 1
  • 27
  • 40
  • 1
    your solution worked perfectly. The instructions on Heroku don't include the code config.mailer_sender = "mail-to-send@from.com". Thx. – ubique May 23 '11 at 15:49
  • so far only the password reset email is working. Do I need to change something for the 'new' user' to work too? – ubique May 24 '11 at 09:04
  • Nope, everything worked for me. Password reset, subscription etc... Check your heroku logs to get your error. – Lucas May 24 '11 at 09:09
  • is the subscription email you mention the :confirmable method, so when a new user signs up they have to click on a link in the email in order to log in? – ubique May 24 '11 at 21:12
  • @ubique Yes, exactly. That's weird that you can send password recovery but not the confirmation mail. – Lucas May 24 '11 at 21:15
  • is the sendgrid password the same that my heroku account?, if is not, can i set it here? https://sendgrid.com/user/account – Ricbermo Feb 17 '14 at 21:39
1

I've used the sendgrid Add-On and it really should just work. Like you said, even the docs say so:

Rails apps using ActionMailer will just work, no setup is needed after the add-on is installed.

So, this makes me think something else is going on. Have you tried using the heroku logs command to see if your application is logging any errors?

markquezada
  • 8,444
  • 6
  • 45
  • 52
  • "Note that a plugin to automatically configure ActionMailer for Rails is installed on our Bamboo stack. The following settings are necessary on Cedar, or for non-Rails apps using ActionMailer on Bamboo." – Mike Atlas May 09 '13 at 19:17
  • Note that when I originally answered the question two years ago, Bamboo was still the default stack. – markquezada May 11 '13 at 08:50
  • 2
    Yep no worries, just trying to keep this relevant and up to date :) – Mike Atlas May 11 '13 at 19:00