Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 - sendgrid setup to support devise

I'm trying to get sendgrid running on my Rails 3 App with Devise, so devise can send out registration emails etc..

I added the following, config/setup_mail.rb:

ActionMailer::Base.smtp_settings = {
  :address => "smtp.sendgrid.net",
  :port => '25',
  :domain => "XXXXXXXXX.com",
  :authentication => :plain,
  :user_name => "[email protected]",
  :password => "XXXXXXXXXX"
}

Shouldn't that be enough for Rails + Devise to send out registration emails? Or do I need something else or a gem of some kind?

The logs show the email being generated but I don't see anything in the log about MAIL being sent successfully or erroring. And my sendgrid account still says 0/200 emails sent.

Is there a better way in Rails to see what's going on when it trys to send the email?

Thanks

like image 455
AnApprentice Avatar asked Nov 05 '22 06:11

AnApprentice


1 Answers

You can erase the setup that you have.

heroku addons:create sendgrid:free

That is the only pieces of code you need to get email configured with heroku.

Make sure you have your host link setup which I think you did because it will cause it to crash but if you haven't:

config.action_mailer.default_url_options = { :host => 'myapp.heroku.com' }

Actually this last lien is different on rails3 so watch out for that :)

The "config" line needs to be added to your "production.rb" file.

like image 56
thenengah Avatar answered Nov 11 '22 05:11

thenengah