Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Up Devise & Sendgrid on Heroku

Tags:

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.

like image 215
ubique Avatar asked May 16 '11 14:05

ubique


People also ask

What is devise in Ruby on Rails?

Devise is the cornerstone gem for Ruby on Rails authentication. With Devise, creating a User that can log in and out of your application is so simple because Devise takes care of all the controllers necessary for user creation ( users_controller ) and for user sessions ( users_sessions_controller ).

Who uses devise?

Who uses Devise? 92 companies reportedly use Devise in their tech stacks, including StackShare, Accenture, and Pipefy.


2 Answers

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 = "[email protected]" 

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 !

like image 126
Lucas Avatar answered Oct 07 '22 20:10

Lucas


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?

like image 30
markquezada Avatar answered Oct 07 '22 18:10

markquezada