Topic: Mail interceptor class not initializing

I have been working on implementing a mail interceptor in a Rails 3.0 application. I have been following the example in RailsCasts #206 … w=comments and am running into an error. I created a development_mail_interceptor.rb file in the application's lib directory with this content ...  class DevelopmentMailInterceptor   def self.delivering_email(message)     message.subject =

Last edited by pransome (2011-11-26 01:30:05)

Re: Mail interceptor class not initializing

Putting "require 'development_mail_interceptor'" at the top of the setup_mail.rb initializers file resolved the error and got the mail interception working.  Is that the best way, "rails way" of resolving it?

Last edited by pransome (2011-11-26 01:28:17)

Re: Mail interceptor class not initializing

You could put this in your environment.rb:

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

And put the setup of the smpt in there as well:

Yourapp::Application.configure do
config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {

not sure which way is better,  six of one, half a dozen of another????

This method keeps everything related to mail in one location, instead of placing configuration is a seperate file.

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Mail interceptor class not initializing

That works, simplifies things and gets rid of the require statement.  Thanks.