user984621
user984621

Reputation: 48443

Exception Notifier in Rails 4 app's not sending email

I am fighting with this issue the whole afternoon.

I used this gem:

gem 'exception_notification'

and then I put this to the /config/environments/production.rb file:

config.action_mailer.default_url_options = { :host => 'http://www.website.com' }

  config.action_mailer.delivery_method = :sendmail
  # Defaults to:
  # config.action_mailer.sendmail_settings = {
  #   location: '/usr/sbin/sendmail',
  #   arguments: '-i -t'
  # }
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  #config.action_mailer.default_options = {from: '[email protected]'}
  config.action_mailer.delivery_method = :smtp

  config.action_mailer.smtp_settings = {
    :address => "smtp.gmail.com",
    :port => 587,
    :domain => "gmail.com",
    :user_name => "[email protected]",
    :password => "password",
    :authentication => "plain",
    :enable_starttls_auto => true
  }

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

But it didn't work out.

So I tried to put it to the /config/application.rb file:

...
module MyApp
  class Application < Rails::Application
    ...
    config.middleware.use ExceptionNotification::Rack,
      :email => {
        :email_prefix => "[App Error] ",
        :sender_address => %{"notifier" <[email protected]>},
        :exception_recipients => %w{[email protected]}
      }
  end
end

How I am testing it - I put to the URL not existing ID, for example /users/1000000. But I don't receive any email with this error to my inbox.

Could anyone help me out with this issue?

Thank you guys.

Upvotes: 1

Views: 602

Answers (1)

NM Pennypacker
NM Pennypacker

Reputation: 6942

I know this is kind of an old post, but I might have an answer. You have two configs for action_mailer in your production config:

config.action_mailer.delivery_method = :sendmail
# and also...
config.action_mailer.delivery_method = :smtp

Might want to remove one of them.

Upvotes: 0

Related Questions