title: Managing critical errors: logging & email
body: <p>What's the best way to send quick one-liner e-mails to an administrative address in Rails?</p>
  
  <p>I am using the Rails <code>Logger</code> to keep track of nasty problems in my application.  One of my controllers is doing mission-critical work and I need to know of any errors ASAP.  When there is an error, I would like my app to send an email to myself, calling attention to the log containing more details.  I'm envisioning something like the following pseudo-code:</p>
  
  <pre><code>begin
     ...
  rescue
     logger.error("Found an error!  Params hash is " + params.to_s)
     email("user@example.com","Critical error in log.  Investigate line " + len(logger.error).to_s)
  end
  </code></pre>
  
  <p>The obvious first place I looked at was <a href="http://api.rubyonrails.org/classes/ActionMailer/Base.html" rel="nofollow noreferrer">ActionMailer</a>.  However, both the documentation and <a href="http://pragprog.com/titles/rails3/agile-web-development-with-rails" rel="nofollow noreferrer">my literature</a> talk about creating a mailer Model, View &amp; Controller, which seems overly complex for what I want:  A very short (one-line) e-mail to an email address where formatting &amp; reply-to address doesn't matter at all.  This brings me back to my question:  What's the best way to send quick one-liner e-mails to an administrative e-mail address in Rails?</p>