---
title: "发生错误的时候发送email邮件提醒"
author: "PBFox"
date: "2008-10-07T11:02:00Z"
tags: []
slug: "email"
draft: false
lastmod: "2008-10-07T11:02:00Z"
id: 479224
url: "https://developerwork.iteye.com/blog/479224"
---

1\. 安装exception\_notification:

1. rubyscript/plugininstall http://dev.rubyonrails.org/svn/rails/plugins/exception\_notification/

2\. 在config/environment.rb文件里面添加这样一行设置接受错误邮件的邮箱：

ExceptionNotifier.exception\_recipients=%w(your@emailaddress.com)  
ExceptionNotifier.sender\_address = %("Application Error" &lt;web@emailaddress.com&gt;)

3\. 在application控制器中加入include ExceptionNotifiable

classApplicationController&lt;ActionController::Base  
includeExceptionNotifiable  
end

4.说明：

只在production环境中有效