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. }  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值