So I'm trying to make a mailer for my site that sends all of the users an email when an order is created. I'm not exactly sure how to go about it, so I've been trying a bunch of different things. Currently, I've screwed up so badly that I can't even get my app to start. (NOT GOOD.)

This is my error message: /Users/Brawain/rails\_projects/sample\_app/config/initializers/setup\_mail.rb:12:in `': uninitialized constant DevelopmentMailInterceptor (NameError)

Currently, this is what my mailer looks like:

Orders controller

```
class OrdersController < ApplicationController
def new

  def create
    @order = Order.new(user_params)
    if @order.save
        UserMailer.work_order(@user).deliver
    else
      render 'new'
    end
  end

end
end

```

A new file I made called development\_mail\_interceptor.rb which is found in the config folder in the environments folder.

```
class DevelopmentMailInterceptor
def self.delivering_email(message)
message.subject = "#{message.to} #{message.subject}"
message.to = "cwolford@andover.edu"
end
end

```

The file work\_order.text.rb in the views for the user\_mailer just has text in it.

In the config folder in the initializers folder I have a file titled setup\_mail.rb

```
ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "student.andover.edu",
  :user_name            => "techmasterswork",
  :password             => "happycrazy",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

ActionMailer::Base.default_url_options[:host] = "localhost:3000"
Mail.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?

```

And then under app I have a folder called mailers where I have the file user\_mailer.rb

```
class UserMailer < ActionMailer::Base
default from: "techmasterswork@gmail.com"

def work_order(user)
  @user = user
  mail to: user.email, subject: "Work Order Form"
end
end

```

I have a sneaking suspicion it should actually end up being order\_mailer.rb, but I'm not sure. Anyway, I know this needs a lot of help. How would you fix this?