`

Exception Notifier - Ruby on Rails plugin

阅读更多
在ROR的wiki里面有文章介绍如何在发生错误的时候发送email邮件提醒,这里有一个插件实现这个功能,配置起来非常简单。

1. 安装方法很简单:
  1. ruby script/plugin install exception_notification  


2. 在config/environment.rb文件里面添加这样一行设置接受错误邮件的邮箱:
  1. ExceptionNotifier.exception_recipients = %w(your@emailaddress.com)  


3. 在application控制器中加入include ExceptionNotifiable
  1. class ApplicationController < ActionController::Base   
  2.      include ExceptionNotifiable    
  3. end  


4.在vendor\plugins\exception_notification\lib\exception_notifier.rb中修改发送邮件的email地址,不然邮件可能发送不出去
@@sender_address = %("Exception Notifier" <alert@emailaddress.com>)

你可能还需要对ActionMailer进行一些设置,例如发送的smtp服务器地址,账户等等:
  1. ActionMailer::Base.raise_delivery_errors = true  
  2. ActionMailer::Base.perform_deliveries = true  
  3. ActionMailer::Base.default_charset = "utf-8"  
  4. ActionMailer::Base.delivery_method = :smtp  
  5. ActionMailer::Base.server_settings = {   
  6.   :address => "smtp.mail.com",   
  7.   :port => 25,   
  8.   :domain => "smtp.mail.com",   
  9.   :authentication => :login,   
  10.   :user_name => "username",   
  11.   :password => "password",   
  12. }  

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics