0

我在我的 Rails 应用程序中使用 exception_notification gem,我想将错误报告电子邮件发送到多个电子邮件 ID。我怎么能做到这一点?

config.middleware.use ExceptionNotification::Rack,
    email: { email_prefix: "[Ay Error] ",
             sender_address: %{"Ay" <adi@yahoo.com>},
             exception_recipients: %w{adi1@yahoo.com}
    }
end

我正在使用邮箱 gem 发送电子邮件。我尝试在谷歌上搜索,但找不到解决方案。提前致谢

4

3 回答 3

1

添加文件config/initializers/exception_notification.rb

添加以下代码

    require 'exception_notification/rails'

    ExceptionNotification.configure do |config|

      ##Send notifications if rails running in production mode
      config.ignore_if do |exception, options|
        not Rails.env.production?
      end

      ##add notifier
      config.add_notifier :email, {
        :email_prefix         => "Error Prefix ",
        :sender_address       => "Sender address",
        :exception_recipients => ['developer1@example.com', 'developer2@example2.com'],
        :delivery_method => :smtp,
        :smtp_settings => {
          :user_name => "User Name",
          :password => "Password",
          :domain => "domain",
          :address => "Address",
          :port => 587,
          :authentication => :plain,
          :enable_starttls_auto => true
        }
      }

  end
于 2015-03-27T13:18:50.497 回答
0

您是否尝试将其添加到列表中?像这样?

exception_recipients: %w{adi1@yahoo.com foo@example.com}

于 2015-02-28T18:21:09.340 回答
0

ExceptionNotification::Notifier.exception_recipients = %w(test1@test.com test2@test.com) ExceptionNotification::Notifier.sender_address = %("Exception Notifier" ) ExceptionNotification::Notifier.email_prefix = "[ERROR: Project Name] "

于 2015-03-01T14:05:10.313 回答