Rails Exception Notification with Sendgrid

428 Views Asked by At

I have installed the exception notifications gem and I am currently using sendgrid as part of my app email sign up/login process.

Below is my github gist which i added the config code in my production.rb but not sure why I am not receiving any email.

https://gist.github.com/tke578/4ff7b2735ddfb5c7c71b

1

There are 1 best solutions below

3
On

I am not sure what went wrong in your code. Try following code this is working one in mine.

On command prompt :

heroku addons:add sendgrid:starter

config/environment.rb:

ActionMailer::Base.smtp_settings = {
  :address        => 'smtp.sendgrid.net',
  :port           => '587',
  :authentication => :plain,
  :user_name      => ENV['SENDGRID_USERNAME'],
  :password       => ENV['SENDGRID_PASSWORD'],
  :domain         => 'heroku.com',
  :enable_starttls_auto => true
}

config/initializers/exception_notification.rb:

AppName::Application.config.middleware.use ExceptionNotification::Rack,
  :email => {
    :email_prefix => "[AppName] ",
    :sender_address => %{"notifier" <[email protected]>},
    :exception_recipients => %w{[email protected]}
  }

Gemfile:

gem 'exception_notification'

config/environments/production.rb:

# config.action_mailer.raise_delivery_errors = false
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true