在rails项目中,用Exception Notification,可以在程序异常时发送通知邮件。
1.安装gem
gem 'exception_notification', :require => 'exception_notifier'
并bundle install
2.安装Exception Notification
在config/initializers/下新建exception_notificatioin.rb文件
AppName::Application.config.middleware.use ExceptionNotifier,
:email_prefix => "[Title] ",
:sender_address => %{"notifier" <notifier@example.com>},
:exception_recipients => %w{send_to@example.com}
如果是开发模式下测试,需要在config/environments/development.rb中配置
config.action_mailer.raise_delivery_errors = true
3.安装邮件代理类库(在ubuntu下)
sudo apt-get install sendmail
本文介绍如何在Rails项目中使用ExceptionNotification gem配置异常邮件通知。包括安装gem、配置中间件及邮件代理等步骤。
793

被折叠的 条评论
为什么被折叠?



