Question

I've got a problem with my smtp settings and Exception Notification gem.

Because I need to send mails from multiple addresses I used the setup described in this post:

http://justinreid.com/configure-actionmailer-to-use-multiple-smtp-settings/

Ruby (/config/initializers/action_mailer.rb)

module ActionMailer
  class Base
    cattr_accessor :smtp_config

    self.smtp_config = YAML::load(File.open("#{Rails.root}/config/smtp.yml"))[Rails.env]

    def self.smtp_settings
      mailer = self.smtp_config[mailer_name]
      @@smtp_settings = mailer.symbolize_keys
    end

  end
end

YAML (/config/smtp.yml)

common: &common
  address: "smtp.gmail.com"
  port: 587
  authentication: "plain"
  enable_starttls_auto: true

development:
  account_mailer:
    <<: *common,
    domain: "mail.dev.domain.com",
    user_name: "support@dev.domain.com",
    password: "password",
    from: "Domain Support "
  message_mailer:
    <<: *common,
    domain: "mail.messages.dev.domain.com",
    user_name: "messenger@messages.dev.domain.com",
    password: "password",
    from: "Domain Messages "
production:
  account_mailer:
    <<: *common,
    domain: "mail.domain.com",
    user_name: "support@domain.com",
    password: "password",
    from: "Domain Support "
  message_mailer:
    <<: *common,
    domain: "mail.messages.domain.com",
    user_name: "messenger@messages.domain.com",
    password: "password",
    from: "Domain Messages "

In the YAML File there are settings for each combination of mailer and environment. Everything works well when I send mails with my mailers. But when I try to use the Exception Notification gem I get no email notification, but an error message in my log file:

An error occurred when sending a notification using 'email' notifier. NoMethodError: undefined method symbolize_keys' for nil:NilClass /home/maurice/rails/abmore_server2/config/initializers/action_mailer.rb:9:in smtp_settings'

It seems to me that Exception Notification gem has an own mailer name and tries to search for the according smtp settings in the smtp.yml which it can't find because it's not defined. I tried to search in the gems lib directory for the mailer name but I can't find it, because I'm more or less new to RoR.

For your Information: Exception Notification is configured in:

Ruby (/config/initializers/exception_notification.rb)

AppName::Application.config.middleware.use ExceptionNotification::Rack,
    :ignore_exceptions => [],
  :email => {
    :email_prefix => "development - error: ",
    :sender_address => "username@username.com",
    :exception_recipients => "recipient@recipient.com",
    :delivery_method => :smtp,
    :smtp_settings => {
      :address => "smtp.gmail.com",
      :port => 587,
      :authentication => "plain",
      :user_name => "username@username.com",
      :password => "password",
      enable_starttls_auto: true
    }
  }

I think I have to search in this file here: https://github.com/smartinez87/exception_notification/blob/master/lib/exception_notifier/email_notifier.rb

Can anyone tell me whats the correct mailer name of the Exception Notification gem, so that I can add it to my smtp.yml file?

I'm using Rails 3.2.x in my project. So I can't use the new :delivery_method_options.

Was it helpful?

Solution

With the help of the debugger gem: https://github.com/cldwalker/debugger and this railscasts tutorial: http://railscasts.com/episodes/54-debugging-ruby-revised?autoplay=true I was able to find it out by myself. The name of the mailer is "exception_notifier".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top