如何在Rails 3.0.3中设置邮件拦截器?

| 我正在使用rails 3.0.3,ruby 1.9.2-p180,mail(2.2.13)。我正在尝试设置邮件拦截器,但出现以下错误
 /home/abhimanyu/Aptana_Studio_3_Workspace/delivery_health_dashboard_03/config/initializers/mailer_config.rb:16:in `<top (required)>\': uninitialized constant DevelopmentMailInterceptor (NameError)
我如何解决它? 我正在使用的代码如下所示:
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
提前致谢。     
已邀请:
        
require \'development_mail_interceptor\' #add this line
ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if  Rails.env.development?
    
        我发现安装mailcatcher gem更容易。然后在development.rb中:
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :address              => \"`localhost`\",
    :port                 => 1025
  }
然后只需运行\“ mailcatcher \”,然后在浏览器中按
http://localhost:1080/
。它在后台运行,但是可以直接从浏览器中退出。如果以这种方式摆动,则可以分形显示text + html视图,源和分析。超级干净。     

要回复问题请先登录注册