title: ActionMailer Not Working
body: <p>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.)</p>
  
  <p>This is my error message: /Users/Brawain/rails_projects/sample_app/config/initializers/setup_mail.rb:12:in `': uninitialized constant DevelopmentMailInterceptor (NameError)</p>
  
  <p>Currently, this is what my mailer looks like:</p>
  
  <p>Orders controller</p>
  
  <pre><code>class OrdersController &lt; 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
  </code></pre>
  
  <p>A new file I made called development_mail_interceptor.rb which is found in the config folder in the environments folder.</p>
  
  <pre><code>class DevelopmentMailInterceptor
  def self.delivering_email(message)
  message.subject = "#{message.to} #{message.subject}"
  message.to = "cwolford@andover.edu"
  end
  end
  </code></pre>
  
  <p>The file work_order.text.rb in the views for the user_mailer just has text in it.</p>
  
  <p>In the config folder in the initializers folder I have a file titled setup_mail.rb</p>
  
  <pre><code>ActionMailer::Base.smtp_settings = {
    :address              =&gt; "smtp.gmail.com",
    :port                 =&gt; 587,
    :domain               =&gt; "student.andover.edu",
    :user_name            =&gt; "techmasterswork",
    :password             =&gt; "happycrazy",
    :authentication       =&gt; "plain",
    :enable_starttls_auto =&gt; true
  }
  
  ActionMailer::Base.default_url_options[:host] = "localhost:3000"
  Mail.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
  </code></pre>
  
  <p>And then under app I have a folder called mailers where I have the file user_mailer.rb</p>
  
  <pre><code>class UserMailer &lt; ActionMailer::Base
  default from: "techmasterswork@gmail.com"
  
  def work_order(user)
    @user = user
    mail to: user.email, subject: "Work Order Form"
  end
  end
  </code></pre>
  
  <p>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?</p>