Question: I am using rails 3.0.3, ruby 1.9.2-p180, mail (2.2.13). I m trying to setup a mail interceptor but I am getting the following error

```
 /home/abhimanyu/Aptana_Studio_3_Workspace/delivery_health_dashboard_03/config/initializers/mailer_config.rb:16:in `<top (required)>': uninitialized constant DevelopmentMailInterceptor (NameError)

```

How do i fix it?

The code I am using is shown below:

```
config/initializer/mailer_config.rb

ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.default_content_type = "text/html"
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => "secure.emailsrvr.com",
:port => '25',
:domain => "domain",
:user_name => "user_name",
:password => "password",
:authentication => :plain

```

}

```
ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if  Rails.env.development?

```

lib/development\_mail\_interceptor.rb

```
class DevelopmentMailInterceptor

  def self.delivering_email(message)
    message.to = "email"
  end

end

```

Thanks in advance.

Answer: 
```
require 'development_mail_interceptor' #add this line
ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if  Rails.env.development?

```
I found it easier to install the [mailcatcher gem](https://rubygems.org/gems/mailcatcher). Then in development.rb:

```
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :address              => "`localhost`",
    :port                 => 1025
  }

```

Then just run "mailcatcher" and hit `http://localhost:1080/` in a browser. It runs in the background, but can be quit directly from the browser. Gives you text+html views, source, and analysis with fractal, if you swing that way. Super-clean.