<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>README.rdoc</filename>
    </added>
    <added>
      <filename>generators/ar_mailer/ar_mailer_generator.rb</filename>
    </added>
    <added>
      <filename>generators/ar_mailer/templates/migration.rb</filename>
    </added>
    <added>
      <filename>generators/ar_mailer/templates/model.rb</filename>
    </added>
    <added>
      <filename>test/resources/action_mailer.rb</filename>
    </added>
    <added>
      <filename>test/test_helper.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,57 @@
+= 2.1.5
+
+* Bugs fixed
+  * Load ar_mailer after environment to fix issue with lazy loading of ActionMailer in Rails 2.3
+
+= 2.1.4
+
+* Bugs fixed
+  * Explicitly require ar_mailer in ar_sendmail because its not getting loaded by the Rails environment for some reason
+
+= 2.1.3
+
+* Tests now pass on gem install
+* Removed deprecated ActionMailer::ARMailer class
+* Bugs fixed
+  * Fixed issue with pre-loading ActionMailer. No use ActionMailer::Base.email_class directly rather than store in ARSendmail instance var so no need to pre-load ActionMailer.
+
+= 2.1.2
+
+* Bugs fixed
+  * Require ar_mailer in ar_sendmail since the change to remove TableName and use email_class
+
+= 2.1.1
+ 
+ * Force gem rebuild
+
+= 2.1.0
+
+* Switched to using a Rails generator for migration and model files. The ar_sendmail options have been removed.
+
+= 2.0.2
+
+* Removed TableName option from ar_sendmail options as its redundant. The Rails environment gets loaded so the settings for email class also get loaded
+* Bugs fixed
+  * Email class reloading issue in development mode causing AR email class defaults to be lost when cached
+
+= 2.0.1
+
+* Added option to use smtp setting of :tls =&gt; false to disable TLS auto start in Ruby 1.8.7+
+* Removed some cruft which can be handled by ActiveSupport
+
+= 2.0.0
+
+* Removed need to use ARMailer subclass. Just set the delivery method and you are ready to go. Backwards compatible with a deprecation notice if you subclass old ARMailer class.
+* Only include SMTP TLS patch if Ruby version &lt; 1.8.7 as it has an alternative. Changes based on Calvin Yu's [cyu] fork.
+* Renamed default migration name to the modern Rails default
+* Only authenticate if emails waiting to be sent
+* Added --version switch to ar_sendmail binary
+* Created a lighthouse account for this project (adzap fork only). See README.
+
+= 1.4.4
+
+* Exit init.d script with message if no mailers defined.
+
 = 1.4.3
 
 * Bugs fixed</diff>
      <filename>History.txt</filename>
    </modified>
    <modified>
      <diff>@@ -11,20 +11,18 @@ ar_mailer_gemspec = Gem::Specification.new do |s|
   s.name = %q{ar_mailer}
   s.version = ActionMailer::ARSendmail::VERSION
   s.required_rubygems_version = Gem::Requirement.new(&quot;&gt;= 0&quot;) if s.respond_to? :required_rubygems_version=
-  s.authors = [&quot;Eric Hodel&quot;]
-  s.date = %q{2008-07-04}
+  s.authors = [&quot;Eric Hodel&quot;, &quot;Adam Meehan&quot;]
   s.default_executable = %q{ar_sendmail}
   s.description = %q{Even delivering email to the local machine may take too long when you have to send hundreds of messages.  ar_mailer allows you to store messages into the database for later delivery by a separate process, ar_sendmail.}
-  s.email = %q{drbrain@segment7.net}
+  s.email = %q{adam.meehan@gmail.com}
   s.executables = [&quot;ar_sendmail&quot;]
-  s.extra_rdoc_files = [&quot;History.txt&quot;, &quot;LICENSE.txt&quot;, &quot;Manifest.txt&quot;, &quot;README.txt&quot;]
-  s.files = [&quot;History.txt&quot;, &quot;LICENSE.txt&quot;, &quot;Manifest.txt&quot;, &quot;README.txt&quot;, &quot;Rakefile&quot;, &quot;bin/ar_sendmail&quot;, &quot;lib/action_mailer/ar_mailer.rb&quot;, &quot;lib/action_mailer/ar_sendmail.rb&quot;, &quot;lib/ar_sendmail_logger.rb&quot;, &quot;lib/smtp_tls.rb&quot;, &quot;share/bsd/ar_sendmail&quot;, &quot;share/linux/ar_sendmail&quot;, &quot;share/linux/ar_sendmail.conf&quot;, &quot;test/action_mailer.rb&quot;, &quot;test/test_armailer.rb&quot;, &quot;test/test_arsendmail.rb&quot;]
+  s.extra_rdoc_files = [&quot;History.txt&quot;, &quot;LICENSE.txt&quot;, &quot;README.rdoc&quot;]
+  s.files = [&quot;History.txt&quot;, &quot;LICENSE.txt&quot;, &quot;README.rdoc&quot;, &quot;Rakefile&quot;, &quot;bin/ar_sendmail&quot;, &quot;generators/ar_mailer/ar_mailer_generator.rb&quot;, &quot;generators/ar_mailer/templates/migration.rb&quot;, &quot;generators/ar_mailer/templates/model.rb&quot;, &quot;lib/action_mailer/ar_mailer.rb&quot;, &quot;lib/action_mailer/ar_sendmail.rb&quot;, &quot;lib/smtp_tls.rb&quot;, &quot;lib/ar_sendmail_logger.rb&quot;, &quot;share/bsd/ar_sendmail&quot;, &quot;share/linux/ar_sendmail&quot;, &quot;share/linux/ar_sendmail.conf&quot;, &quot;test/resources/action_mailer.rb&quot;, &quot;test/test_armailer.rb&quot;, &quot;test/test_arsendmail.rb&quot;, &quot;test/test_helper.rb&quot;]
   s.has_rdoc = true
-  s.homepage = %q{http://seattlerb.org/ar_mailer}
-  s.rdoc_options = [&quot;--main&quot;, &quot;README.txt&quot;]
+  s.homepage = %q{http://github.com/adzap/ar_mailer}
+  s.rdoc_options = [&quot;--main&quot;, &quot;README.rdoc&quot;]
   s.require_paths = [&quot;lib&quot;]
   s.rubyforge_project = %q{seattlerb}
-  s.rubygems_version = %q{1.2.0}
   s.summary = %q{A two-phase delivery agent for ActionMailer}
   s.test_files = [&quot;test/test_armailer.rb&quot;, &quot;test/test_arsendmail.rb&quot;]
 end 
@@ -33,20 +31,16 @@ Rake::GemPackageTask.new(ar_mailer_gemspec) do |pkg|
   pkg.gem_spec = ar_mailer_gemspec
 end
  
-namespace :gem do
-  namespace :spec do
-    desc &quot;Update ar_mailer.gemspec&quot;
-    task :generate do
-      File.open(&quot;ar_mailer.gemspec&quot;, &quot;w&quot;) do |f|
-        f.puts(ar_mailer_gemspec.to_ruby)
-      end
-    end
+desc &quot;Update ar_mailer.gemspec&quot;
+task :make_spec do
+  File.open(&quot;ar_mailer.gemspec&quot;, &quot;w&quot;) do |f|
+    f.puts(ar_mailer_gemspec.to_ruby)
   end
 end
  
 desc &quot;Build packages and install&quot;
 task :install =&gt; :package do
-  sh %{sudo gem install --local pkg/ar_mailer-#{ActionMailer::ARSendmail::VERSION}}
+  sh %{sudo gem install --local --test pkg/ar_mailer-#{ActionMailer::ARSendmail::VERSION}}
 end
 
 desc 'Default: run unit tests.'
@@ -55,6 +49,6 @@ task :default =&gt; :test
 desc 'Test the ar_mailer gem.'
 Rake::TestTask.new(:test) do |t|
   t.libs &lt;&lt; 'lib' &lt;&lt; 'test'
-  t.pattern = 'test/**/test_*.rb'
+  t.test_files = FileList['test/**/test_*.rb'].exclude(&quot;test/test_helper.rb&quot;)
   t.verbose = true
 end</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,30 +1,31 @@
-Gem::Specification.new do |s| 
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
   s.name = %q{ar_mailer}
-  s.version = &quot;1.4.6&quot;
+  s.version = &quot;2.1.5&quot;
 
   s.required_rubygems_version = Gem::Requirement.new(&quot;&gt;= 0&quot;) if s.respond_to? :required_rubygems_version=
-  s.authors = [&quot;Eric Hodel&quot;]
-  s.date = %q{2008-07-04}
+  s.authors = [&quot;Eric Hodel&quot;, &quot;Adam Meehan&quot;]
+  s.date = %q{2009-07-06}
   s.default_executable = %q{ar_sendmail}
   s.description = %q{Even delivering email to the local machine may take too long when you have to send hundreds of messages.  ar_mailer allows you to store messages into the database for later delivery by a separate process, ar_sendmail.}
-  s.email = %q{drbrain@segment7.net}
+  s.email = %q{adam.meehan@gmail.com}
   s.executables = [&quot;ar_sendmail&quot;]
-  s.extra_rdoc_files = [&quot;History.txt&quot;, &quot;LICENSE.txt&quot;, &quot;Manifest.txt&quot;, &quot;README.txt&quot;]
-  s.files = [&quot;History.txt&quot;,&quot;LICENSE.txt&quot;, &quot;Manifest.txt&quot;, &quot;README.txt&quot;, &quot;Rakefile&quot;, &quot;bin/ar_sendmail&quot;, &quot;lib/action_mailer/ar_mailer.rb&quot;, &quot;lib/action_mailer/ar_sendmail.rb&quot;, &quot;lib/ar_sendmail_logger.rb&quot;, &quot;lib/smtp_tls.rb&quot;, &quot;share/bsd/ar_sendmail&quot;, &quot;share/linux/ar_sendmail&quot;, &quot;share/linux/ar_sendmail.conf&quot;, &quot;test/action_mailer.rb&quot;, &quot;test/test_armailer.rb&quot;, &quot;test/test_arsendmail.rb&quot;]
-  s.has_rdoc = true
-  s.homepage = %q{http://seattlerb.org/ar_mailer}
-  s.rdoc_options = [&quot;--main&quot;, &quot;README.txt&quot;]
+  s.extra_rdoc_files = [&quot;History.txt&quot;, &quot;LICENSE.txt&quot;, &quot;README.rdoc&quot;]
+  s.files = [&quot;History.txt&quot;, &quot;LICENSE.txt&quot;, &quot;README.rdoc&quot;, &quot;Rakefile&quot;, &quot;bin/ar_sendmail&quot;, &quot;generators/ar_mailer/ar_mailer_generator.rb&quot;, &quot;generators/ar_mailer/templates/migration.rb&quot;, &quot;generators/ar_mailer/templates/model.rb&quot;, &quot;lib/action_mailer/ar_mailer.rb&quot;, &quot;lib/action_mailer/ar_sendmail.rb&quot;, &quot;lib/smtp_tls.rb&quot;, &quot;lib/ar_sendmail_logger.rb&quot;, &quot;share/bsd/ar_sendmail&quot;, &quot;share/linux/ar_sendmail&quot;, &quot;share/linux/ar_sendmail.conf&quot;, &quot;test/resources/action_mailer.rb&quot;, &quot;test/test_armailer.rb&quot;, &quot;test/test_arsendmail.rb&quot;, &quot;test/test_helper.rb&quot;]
+  s.homepage = %q{http://github.com/adzap/ar_mailer}
+  s.rdoc_options = [&quot;--main&quot;, &quot;README.rdoc&quot;]
   s.require_paths = [&quot;lib&quot;]
   s.rubyforge_project = %q{seattlerb}
-  s.rubygems_version = %q{1.2.0}
+  s.rubygems_version = %q{1.3.4}
   s.summary = %q{A two-phase delivery agent for ActionMailer}
   s.test_files = [&quot;test/test_armailer.rb&quot;, &quot;test/test_arsendmail.rb&quot;]
 
   if s.respond_to? :specification_version then
     current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
-    s.specification_version = 2
+    s.specification_version = 3
 
-    if current_version &gt;= 3 then
+    if Gem::Version.new(Gem::RubyGemsVersion) &gt;= Gem::Version.new('1.2.0') then
     else
     end
   else</diff>
      <filename>ar_mailer.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -1,111 +1,31 @@
-require 'action_mailer'
-
 ##
 # Adds sending email through an ActiveRecord table as a delivery method for
 # ActionMailer.
 #
-# == Converting to ActionMailer::ARMailer
-#
-# Go to your Rails project:
-#
-#   $ cd your_rails_project
-#
-# Create a new migration:
-#
-#   $ ar_sendmail --create-migration
-#
-# You'll need to redirect this into a file.  If you want a different name
-# provide the --table-name option.
-#
-# Create a new model:
-#
-#   $ ar_sendmail --create-model
-#
-# You'll need to redirect this into a file.  If you want a different name
-# provide the --table-name option.
-#
-# Change your email classes to inherit from ActionMailer::ARMailer instead of
-# ActionMailer::Base:
-#
-#   --- app/model/emailer.rb.orig   2006-08-10 13:16:33.000000000 -0700
-#   +++ app/model/emailer.rb        2006-08-10 13:16:43.000000000 -0700
-#   @@ -1,4 +1,4 @@
-#   -class Emailer &lt; ActionMailer::Base
-#   +class Emailer &lt; ActionMailer::ARMailer
-#    
-#   def comment_notification(comment)
-#     from comment.author.email
-#
-# You'll need to be sure to set the From address for your emails.  Something
-# like:
-#
-#   def list_send(recipient)
-#     from 'no_reply@example.com'
-#     # ...
-#
-# Edit config/environment.rb and require ar_mailer.rb:
-#
-#  require 'action_mailer/ar_mailer'
-#
-# Edit config/environments/production.rb and set the delivery agent:
-#
-#   $ grep delivery_method config/environments/production.rb
-#   ActionMailer::Base.delivery_method = :activerecord
-#
-# Run ar_sendmail:
-#
-#   $ ar_sendmail
-#
-# You can also run it from cron with -o, or as a daemon with -d.
-#
-# See &lt;tt&gt;ar_sendmail -h&lt;/tt&gt; for full details.
-#
-# == Alternate Mail Storage
-#
-# If you want to set the ActiveRecord model that emails will be stored in,
-# see ActionMailer::ARMailer::email_class=
-
-class ActionMailer::ARMailer &lt; ActionMailer::Base
-
-  @@email_class = Email
 
-  ##
-  # Current email class for deliveries.
-
-  def self.email_class
-    @@email_class
-  end
+class ActionMailer::Base
 
   ##
-  # Sets the email class for deliveries.
+  # Set the email class for deliveries. Handle class reloading issues which prevents caching the email class.
+  #
+  @@email_class_name = 'Email'
 
   def self.email_class=(klass)
-    @@email_class = klass
+    @@email_class_name = klass.to_s
   end
 
-  @@context_header = 'X-Delivery-Context'
-
-  def self.context_header
-    @@context_header
+  def self.email_class
+    @@email_class_name.constantize
   end
-    
+
   ##
   # Adds +mail+ to the Email table.  Only the first From address for +mail+ is
   # used.
 
   def perform_delivery_activerecord(mail)
     mail.destinations.each do |destination|
-      # If the email has the context header set, assume that the caller added a context column
-      if @@context_header &amp;&amp; mail.header_string(@@context_header)
-        @@email_class.create(
-          :mail =&gt; mail.encoded, :to =&gt; destination, 
-          :from =&gt; mail.from.first, :context =&gt; mail.header_string(@@context_header)
-        )
-      else
-        @@email_class.create(:mail =&gt; mail.encoded, :to =&gt; destination, :from =&gt; mail.from.first)
-      end
+      self.class.email_class.create :mail =&gt; mail.encoded, :to =&gt; destination, :from =&gt; mail.from.first
     end
   end
 
 end
-</diff>
      <filename>lib/action_mailer/ar_mailer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,17 +1,9 @@
 require 'optparse'
 require 'net/smtp'
-require 'smtp_tls'
+require 'smtp_tls' unless Net::SMTP.instance_methods.include?(&quot;enable_starttls_auto&quot;)
 require 'ar_sendmail_logger'
 require 'rubygems'
 
-class Object # :nodoc:
-  unless respond_to? :path2class then
-    def self.path2class(path)
-      path.split(/::/).inject self do |k,n| k.const_get n end
-    end
-  end
-end
-
 ##
 # Hack in RSET
 
@@ -30,8 +22,6 @@ class SMTP # :nodoc:
 end
 end
 
-module ActionMailer; end # :nodoc:
-
 ##
 # ActionMailer::ARSendmail delivers email from the email table to the
 # SMTP server configured in your application's config/environment.rb.
@@ -46,16 +36,15 @@ module ActionMailer; end # :nodoc:
 # The interesting options are:
 # * --daemon
 # * --mailq
-# * --create-migration
-# * --create-model
-# * --table-name
+
+module ActionMailer; end
 
 class ActionMailer::ARSendmail
 
   ##
   # The version of ActionMailer::ARSendmail you are running.
 
-  VERSION = '1.4.6'
+  VERSION = '2.1.5'
 
   ##
   # Maximum number of times authentication will be consecutively retried
@@ -81,13 +70,7 @@ class ActionMailer::ARSendmail
   # Be verbose
 
   attr_accessor :verbose
-
-  ##
-  # ActiveRecord class that holds emails
-
-  attr_reader :email_class
-  
-  attr_reader :logger
+ 
 
   ##
   # True if only one delivery attempt will be made per call to run
@@ -98,6 +81,11 @@ class ActionMailer::ARSendmail
   # Times authentication has failed
 
   attr_accessor :failed_auth_count
+  
+  ##
+  # Logs the value of this header for successfully sent emails
+  
+  attr_accessor :log_header
 
   @@pid_file = nil
 
@@ -110,50 +98,14 @@ class ActionMailer::ARSendmail
   end
 
   ##
-  # Creates a new migration using +table_name+ and prints it on stdout.
-
-  def self.create_migration(table_name)
-    require 'active_support'
-    puts &lt;&lt;-EOF
-class Add#{table_name.classify} &lt; ActiveRecord::Migration
-  def self.up
-    create_table :#{table_name.tableize} do |t|
-      t.column :from, :string
-      t.column :to, :string
-      t.column :last_send_attempt, :integer, :default =&gt; 0
-      t.column :mail, :text
-      t.column :created_on, :datetime
-    end
-  end
-
-  def self.down
-    drop_table :#{table_name.tableize}
-  end
-end
-    EOF
-  end
-
-  ##
-  # Creates a new model using +table_name+ and prints it on stdout.
-
-  def self.create_model(table_name)
-    require 'active_support'
-    puts &lt;&lt;-EOF
-class #{table_name.classify} &lt; ActiveRecord::Base
-end
-    EOF
-  end
-
-  ##
   # Prints a list of unsent emails and the last delivery attempt, if any.
   #
   # If ActiveRecord::Timestamp is not being used the arrival time will not be
   # known.  See http://api.rubyonrails.org/classes/ActiveRecord/Timestamp.html
   # to learn how to enable ActiveRecord::Timestamp.
 
-  def self.mailq(table_name)
-    klass = table_name.split('::').inject(Object) { |k,n| k.const_get n }
-    emails = klass.find :all
+  def self.mailq
+    emails = ActionMailer::Base.email_class.find :all
 
     if emails.empty? then
       puts &quot;Mail queue is empty&quot;
@@ -202,9 +154,7 @@ end
     options[:MaxAge] = 86400 * 7
     options[:Once] = false
     options[:RailsEnv] = ENV['RAILS_ENV']
-    options[:TableName] = 'Email'
     options[:Pidfile] = options[:Chdir] + '/log/ar_sendmail.pid'
-    options[:LogFile] = nil
 
     opts = OptionParser.new do |opts|
       opts.banner = &quot;Usage: #{name} [options]&quot;
@@ -257,12 +207,6 @@ end
         options[:Pidfile] = pidfile
       end
 
-      opts.on(&quot;-l&quot;, &quot;--logfile LOGFILE&quot;,
-              &quot;Set the logfile location&quot;,
-              &quot;Default: #{options[:Chdir]}#{options[:LogFile]}&quot;, String) do |logfile|
-        options[:LogFile] = logfile
-      end          
-
       opts.on(      &quot;--mailq&quot;,
               &quot;Display a list of emails waiting to be sent&quot;) do |mailq|
         options[:MailQ] = true
@@ -271,18 +215,6 @@ end
       opts.separator ''
       opts.separator 'Setup Options:'
 
-      opts.on(      &quot;--create-migration&quot;,
-              &quot;Prints a migration to add an Email table&quot;,
-              &quot;to stdout&quot;) do |create|
-        options[:Migrate] = true
-      end
-
-      opts.on(      &quot;--create-model&quot;,
-              &quot;Prints a model for an Email ActiveRecord&quot;,
-              &quot;object to stdout&quot;) do |create|
-        options[:Model] = true
-      end
-
       opts.separator ''
       opts.separator 'Generic Options:'
 
@@ -294,20 +226,23 @@ end
         options[:Chdir] = path
       end
 
+      opts.on(      &quot;--log-file PATH_AND_FILE&quot;,
+              &quot;Full path to the file the mailer should log to&quot;,
+              &quot;Default: RAILS_ROOT/log/RAILS_ENV.log&quot;) do |log_file|
+        options[:LogFile] = log_file
+      end
+      
+      opts.on(      &quot;--log-header SOME_HEADER&quot;,
+              &quot;Logs the value of the specified header once an email gets sent&quot;) do |header|
+        options[:LogHeader] = header
+      end
+
       opts.on(&quot;-e&quot;, &quot;--environment RAILS_ENV&quot;,
               &quot;Set the RAILS_ENV constant&quot;,
               &quot;Default: #{options[:RailsEnv]}&quot;) do |env|
         options[:RailsEnv] = env
       end
 
-      opts.on(&quot;-t&quot;, &quot;--table-name TABLE_NAME&quot;,
-              &quot;Name of table holding emails&quot;,
-              &quot;Used for both sendmail and&quot;,
-              &quot;migration creation&quot;,
-              &quot;Default: #{options[:TableName]}&quot;) do |name|
-        options[:TableName] = name
-      end
-
       opts.on(&quot;-v&quot;, &quot;--[no-]verbose&quot;,
               &quot;Be verbose&quot;,
               &quot;Default: #{options[:Verbose]}&quot;) do |verbose|
@@ -319,23 +254,26 @@ end
         usage opts
       end
 
+      opts.on(&quot;--version&quot;, &quot;Version of ARMailer&quot;) do
+        usage &quot;ar_mailer #{VERSION} (adzap fork)&quot;
+      end
+
       opts.separator ''
     end
 
     opts.parse! args
 
-    return options if options.include? :Migrate or options.include? :Model
-
     ENV['RAILS_ENV'] = options[:RailsEnv]
 
     Dir.chdir options[:Chdir] do
       begin
         require 'config/environment'
+        require 'action_mailer/ar_mailer'
       rescue LoadError
         usage opts, &lt;&lt;-EOF
 #{name} must be run from a Rails application's root to deliver email.
 #{Dir.pwd} does not appear to be a Rails application root.
-          EOF
+        EOF
       end
     end
 
@@ -348,14 +286,8 @@ end
   def self.run(args = ARGV)
     options = process_args args
 
-    if options.include? :Migrate then
-      create_migration options[:TableName]
-      exit
-    elsif options.include? :Model then
-      create_model options[:TableName]
-      exit
-    elsif options.include? :MailQ then
-      mailq options[:TableName]
+    if options.include? :MailQ then
+      mailq
       exit
     end
 
@@ -410,24 +342,22 @@ end
   # Valid options are:
   # &lt;tt&gt;:BatchSize&lt;/tt&gt;:: Maximum number of emails to send per delay
   # &lt;tt&gt;:Delay&lt;/tt&gt;:: Delay between deliver attempts
-  # &lt;tt&gt;:TableName&lt;/tt&gt;:: Table name that stores the emails
   # &lt;tt&gt;:Once&lt;/tt&gt;:: Only attempt to deliver emails once when run is called
   # &lt;tt&gt;:Verbose&lt;/tt&gt;:: Be verbose.
 
   def initialize(options = {})
     options[:Delay] ||= 60
-    options[:TableName] ||= 'Email'
     options[:MaxAge] ||= 86400 * 7
 
     @batch_size = options[:BatchSize]
     @delay = options[:Delay]
-    @email_class = Object.path2class options[:TableName]
     @once = options[:Once]
     @verbose = options[:Verbose]
     @max_age = options[:MaxAge]
-
+    @log_header = options[:LogHeader]
+    
     @failed_auth_count = 0
-    @logger = ArSendmailLogger.new(options[:LogFile] || options[:Chdir] + '/log/ar_sendmail.log')
+    @logger = options[:LogFile] ? ARSendmailLogger.new(options[:LogFile]) : ActionMailer::Base.logger
   end
 
   ##
@@ -438,7 +368,7 @@ end
     return if @max_age == 0
     timeout = Time.now - @max_age
     conditions = ['last_send_attempt &gt; 0 and created_on &lt; ?', timeout]
-    mail = @email_class.destroy_all conditions
+    mail = ActionMailer::Base.email_class.destroy_all conditions
 
     log &quot;expired #{mail.length} emails from the queue&quot;
   end
@@ -447,29 +377,40 @@ end
   # Delivers +emails+ to ActionMailer's SMTP server and destroys them.
 
   def deliver(emails)
-    return if emails.empty?
-    user = smtp_settings[:user] || smtp_settings[:user_name]
-    Net::SMTP.start smtp_settings[:address], smtp_settings[:port],
-                    smtp_settings[:domain], user,
-                    smtp_settings[:password],
-                    smtp_settings[:authentication],
-                    smtp_settings[:tls] do |smtp|
+    settings = [
+      smtp_settings[:domain],
+      (smtp_settings[:user] || smtp_settings[:user_name]),
+      smtp_settings[:password],
+      smtp_settings[:authentication]
+    ]
+    
+    smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
+    if smtp.respond_to?(:enable_starttls_auto)
+      smtp.enable_starttls_auto unless smtp_settings[:tls] == false
+    else
+      settings &lt;&lt; smtp_settings[:tls]
+    end
+
+    smtp.start(*settings) do |session|
       @failed_auth_count = 0
       until emails.empty? do
         email = emails.shift
         begin
-          res = smtp.send_message email.mail, email.from, email.to
-          email.destroy
-          if email.respond_to?(:context) &amp;&amp; email.context.to_s != ''
-            log &quot;sent email %011d [%s] from %s to %s: %p&quot; % [email.id, email.context, email.from, email.to, res]
-          else
-            log &quot;sent email %011d from %s to %s: %p&quot; % [email.id, email.from, email.to, res]
+          res = session.send_message email.mail, email.from, email.to
+          hdr = ''
+          
+          if @log_header &amp;&amp; email.mail =~ /#{@log_header}: (.+)/
+            hdr = &quot;[#{$1.chomp}] &quot;
           end
+
+          email.destroy
+          log &quot;sent email %011d %sfrom %s to %s: %p&quot; %
+                [email.id, hdr, email.from, email.to, res]
         rescue Net::SMTPFatalError =&gt; e
           log &quot;5xx error sending email %d, removing from queue: %p(%s):\n\t%s&quot; %
                 [email.id, e.message, e.class, e.backtrace.join(&quot;\n\t&quot;)]
           email.destroy
-          smtp.reset
+          session.reset
         rescue Net::SMTPServerBusy =&gt; e
           log &quot;server too busy, sleeping #{@delay} seconds&quot;
           sleep delay
@@ -479,7 +420,7 @@ end
           email.save rescue nil
           log &quot;error sending email %d: %p(%s):\n\t%s&quot; %
                 [email.id, e.message, e.class, e.backtrace.join(&quot;\n\t&quot;)]
-          smtp.reset
+          session.reset
         end
       end
     end
@@ -512,7 +453,7 @@ end
   def find_emails
     options = { :conditions =&gt; ['last_send_attempt &lt; ?', Time.now.to_i - 300] }
     options[:limit] = batch_size unless batch_size.nil?
-    mail = @email_class.find :all, options
+    mail = ActionMailer::Base.email_class.find :all, options
 
     log &quot;found #{mail.length} emails to send&quot;
     mail
@@ -532,7 +473,7 @@ end
   def log(message)
     message = &quot;ar_sendmail #{Time.now}: #{message}&quot;
     $stderr.puts message if @verbose
-    logger.info(message)
+    @logger.info message
   end
 
   ##
@@ -546,7 +487,8 @@ end
       now = Time.now
       begin
         cleanup
-        deliver find_emails
+        emails = find_emails
+        deliver(emails) unless emails.empty?
       rescue ActiveRecord::Transactions::TransactionError
       end
       break if @once
@@ -567,4 +509,3 @@ end
   end
 
 end
-</diff>
      <filename>lib/action_mailer/ar_sendmail.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,11 @@
 require 'logger'
 
-class ArSendmailLogger &lt; ::Logger
+class ARSendmailLogger &lt; ::Logger
+
+  def initialize(path)
+    FileUtils.mkdir_p(File.dirname(path))
+    super(path)
+  end
 
   def format_message(severity, timestamp, progname, message)
     &quot;#{message}\n&quot;</diff>
      <filename>lib/ar_sendmail_logger.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,11 @@ require 'yaml'
 config_file = '/etc/ar_sendmail.conf'
 
 begin
-  config = YAML::load(IO.read(config_file)) 
+  config = YAML::load(IO.read(config_file)) || {}
+  if config.empty? || (config.has_key?('defaults') &amp;&amp; config.size == 1)
+    puts &quot;No mailers defined. Exiting.&quot;
+    exit
+  end
 rescue Errno::ENOENT
   puts &quot;Config file not found at '#{config_file}'!&quot;
   exit
@@ -30,8 +34,7 @@ def start(app, options)
 end
 
 def stop(app, options)
-  path = options['chdir']
-  pid_file = File.expand_path(options['pidfile'], path)
+  pid_file = File.expand_path(options['pidfile'], options['chdir'])
   if File.exist? pid_file
     begin
       pid = open(pid_file).read.to_i</diff>
      <filename>share/linux/ar_sendmail</filename>
    </modified>
    <modified>
      <diff>@@ -1,20 +1,13 @@
-require 'test/unit'
-require 'action_mailer'
-require 'action_mailer/ar_mailer'
+require File.expand_path(File.dirname(__FILE__) + '/test_helper')
 
-##
-# Pretend mailer
-
-class Mailer &lt; ActionMailer::ARMailer
+class Mailer &lt; ActionMailer::Base
+  self.delivery_method = :activerecord
 
   def mail
     @mail = Object.new
     def @mail.encoded() 'email' end
     def @mail.from() ['nobody@example.com'] end
     def @mail.destinations() %w[user1@example.com user2@example.com] end
-    def @mail.header_string(header_name, default = nil) 
-      default
-    end  
   end
 
 end
@@ -25,15 +18,15 @@ class TestARMailer &lt; Test::Unit::TestCase
     Mailer.email_class = Email
 
     Email.records.clear
-    Mail.records.clear
+    Newsletter.records.clear
   end
 
   def test_self_email_class_equals
-    Mailer.email_class = Mail
+    Mailer.email_class = Newsletter
 
     Mailer.deliver_mail
 
-    assert_equal 2, Mail.records.length
+    assert_equal 2, Newsletter.records.length
   end
 
   def test_perform_delivery_activerecord</diff>
      <filename>test/test_armailer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,4 @@
-require 'test/unit'
-require 'action_mailer'
-require 'action_mailer/ar_sendmail'
-require 'rubygems'
-require 'test/zentest_assertions'
+require File.expand_path(File.dirname(__FILE__) + '/test_helper')
 
 class ActionMailer::ARSendmail
   attr_accessor :slept
@@ -12,7 +8,7 @@ class ActionMailer::ARSendmail
   end
 end
 
-class TestARSendmail &lt; Test::Unit::TestCase
+class TestARSendmail &lt; MiniTest::Unit::TestCase
 
   def setup
     ActionMailer::Base.reset
@@ -22,6 +18,8 @@ class TestARSendmail &lt; Test::Unit::TestCase
     @sm = ActionMailer::ARSendmail.new
     @sm.verbose = true
 
+    Net::SMTP.clear_on_start
+
     @include_c_e = ! $&quot;.grep(/config\/environment.rb/).empty?
     $&quot; &lt;&lt; 'config/environment.rb' unless @include_c_e
   end
@@ -30,43 +28,8 @@ class TestARSendmail &lt; Test::Unit::TestCase
     $&quot;.delete 'config/environment.rb' unless @include_c_e
   end
 
-  def test_class_create_migration
-    out, = util_capture do
-      ActionMailer::ARSendmail.create_migration 'Mail'
-    end
-
-    expected = &lt;&lt;-EOF
-class AddMail &lt; ActiveRecord::Migration
-  def self.up
-    create_table :mail do |t|
-      t.column :from, :string
-      t.column :to, :string
-      t.column :last_send_attempt, :integer, :default =&gt; 0
-      t.column :mail, :text
-      t.column :created_on, :datetime
-    end
-  end
-
-  def self.down
-    drop_table :mail
-  end
-end
-    EOF
-
-    assert_equal expected, out
-  end
-
-  def test_class_create_model
-    out, = util_capture do
-      ActionMailer::ARSendmail.create_model 'Mail'
-    end
-
-    expected = &lt;&lt;-EOF
-class Mail &lt; ActiveRecord::Base
-end
-    EOF
-
-    assert_equal expected, out
+  def strip_log_prefix(line)
+    line.gsub(/ar_sendmail .+ \d{4}: /,'')
   end
 
   def test_class_mailq
@@ -76,11 +39,11 @@ end
                  :mail =&gt; 'body1'
     last = Email.create :from =&gt; nobody, :to =&gt; 'recip@h2.example.com',
                         :mail =&gt; 'body2'
+    last_attempt_time = Time.parse('Thu Aug 10 2006 11:40:05')
+    last.last_send_attempt = last_attempt_time.to_i
 
-    last.last_send_attempt = Time.parse('Thu Aug 10 2006 11:40:05').to_i
-
-    out, err = util_capture do
-      ActionMailer::ARSendmail.mailq 'Email'
+    out, err = capture_io do
+      ActionMailer::ARSendmail.mailq
     end
 
     expected = &lt;&lt;-EOF
@@ -98,13 +61,13 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 -- 0 Kbytes in 3 Requests.
     EOF
 
-    expected = expected % Time.new.strftime('%z')
+    expected = expected % last_attempt_time.strftime('%z')
     assert_equal expected, out
   end
 
   def test_class_mailq_empty
-    out, err = util_capture do
-      ActionMailer::ARSendmail.mailq 'Email'
+    out, err = capture_io do
+      ActionMailer::ARSendmail.mailq
     end
 
     assert_equal &quot;Mail queue is empty\n&quot;, out
@@ -114,17 +77,14 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     @sm = ActionMailer::ARSendmail.new
 
     assert_equal 60, @sm.delay
-    assert_equal Email, @sm.email_class
     assert_equal nil, @sm.once
     assert_equal nil, @sm.verbose
     assert_equal nil, @sm.batch_size
 
     @sm = ActionMailer::ARSendmail.new :Delay =&gt; 75, :Verbose =&gt; true,
-                                       :TableName =&gt; 'Object', :Once =&gt; true,
-                                       :BatchSize =&gt; 1000
+                                       :Once =&gt; true, :BatchSize =&gt; 1000
 
     assert_equal 75, @sm.delay
-    assert_equal Object, @sm.email_class
     assert_equal true, @sm.once
     assert_equal true, @sm.verbose
     assert_equal 1000, @sm.batch_size
@@ -155,7 +115,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 
     argv = %w[-c /nonexistent]
     
-    out, err = util_capture do
+    out, err = capture_io do
       assert_raises SystemExit do
         ActionMailer::ARSendmail.process_args argv
       end
@@ -218,7 +178,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 
   def test_class_parse_args_mailq
     options = ActionMailer::ARSendmail.process_args []
-    deny_includes options, :MailQ
+    refute_includes options, :MailQ
 
     argv = %w[--mailq]
     
@@ -238,33 +198,11 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     assert_equal 86400, options[:MaxAge]
   end
 
-  def test_class_parse_args_migration
-    options = ActionMailer::ARSendmail.process_args []
-    deny_includes options, :Migration
-
-    argv = %w[--create-migration]
-    
-    options = ActionMailer::ARSendmail.process_args argv
-
-    assert_equal true, options[:Migrate]
-  end
-
-  def test_class_parse_args_model
-    options = ActionMailer::ARSendmail.process_args []
-    deny_includes options, :Model
-
-    argv = %w[--create-model]
-    
-    options = ActionMailer::ARSendmail.process_args argv
-
-    assert_equal true, options[:Model]
-  end
-
   def test_class_parse_args_no_config_environment
     $&quot;.delete 'config/environment.rb'
 
-    out, err = util_capture do
-      assert_raise SystemExit do
+    out, err = capture_io do
+      assert_raises SystemExit do
         ActionMailer::ARSendmail.process_args []
       end
     end
@@ -273,35 +211,6 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     $&quot; &lt;&lt; 'config/environment.rb' if @include_c_e
   end
 
-  def test_class_parse_args_no_config_environment_migrate
-    $&quot;.delete 'config/environment.rb'
-
-    out, err = util_capture do
-      ActionMailer::ARSendmail.process_args %w[--create-migration]
-    end
-
-    assert true # count
-
-  ensure
-    $&quot; &lt;&lt; 'config/environment.rb' if @include_c_e
-  end
-
-  def test_class_parse_args_no_config_environment_model
-    $&quot;.delete 'config/environment.rb'
-
-    out, err = util_capture do
-      ActionMailer::ARSendmail.process_args %w[--create-model]
-    end
-
-    assert true # count
-
-  rescue SystemExit
-    flunk 'Should not exit'
-
-  ensure
-    $&quot; &lt;&lt; 'config/environment.rb' if @include_c_e
-  end
-
   def test_class_parse_args_once
     argv = %w[-o]
     
@@ -316,38 +225,24 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     assert_equal true, options[:Once]
   end
 
-  def test_class_parse_args_table_name
-    argv = %w[-t Email]
-    
-    options = ActionMailer::ARSendmail.process_args argv
-
-    assert_equal 'Email', options[:TableName]
-
-    argv = %w[--table-name=Email]
-    
-    options = ActionMailer::ARSendmail.process_args argv
-
-    assert_equal 'Email', options[:TableName]
-  end
-
   def test_class_usage
-    out, err = util_capture do
+    out, err = capture_io do
       assert_raises SystemExit do
         ActionMailer::ARSendmail.usage 'opts'
       end
     end
 
     assert_equal '', out
-    assert_equal &quot;opts\n&quot;, err
+    assert_equal &quot;opts\n&quot;, strip_log_prefix(err)
 
-    out, err = util_capture do
+    out, err = capture_io do
       assert_raises SystemExit do
         ActionMailer::ARSendmail.usage 'opts', 'hi'
       end
     end
 
     assert_equal '', out
-    assert_equal &quot;hi\n\nopts\n&quot;, err
+    assert_equal &quot;hi\n\nopts\n&quot;, strip_log_prefix(err)
   end
 
   def test_cleanup
@@ -357,12 +252,12 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     e3 = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
     e3.last_send_attempt = Time.now
 
-    out, err = util_capture do
+    out, err = capture_io do
       @sm.cleanup
     end
 
     assert_equal '', out
-    assert err.index(&quot;expired 1 emails from the queue\n&quot;)
+    assert_equal &quot;expired 1 emails from the queue\n&quot;, strip_log_prefix(err)
     assert_equal 2, Email.records.length
 
     assert_equal [e1, e2], Email.records
@@ -375,7 +270,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 
     @sm.max_age = 0
 
-    out, err = util_capture do
+    out, err = capture_io do
       @sm.cleanup
     end
 
@@ -383,38 +278,41 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     assert_equal 2, Email.records.length
   end
 
-  def test_context
-    email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from', :context =&gt; 'lemon'
-
-    out, err = util_capture do
-      @sm.deliver [email]
-    end
-
-    assert err.index('[lemon]')
-    
-    email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from', :context =&gt; ''
+  def test_deliver
+    email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
 
-    out, err = util_capture do
+    out, err = capture_io do
       @sm.deliver [email]
     end
 
-    assert !err.index('[]')
-  end    
+    assert_equal 1, Net::SMTP.deliveries.length
+    assert_equal ['body', 'from', 'to'], Net::SMTP.deliveries.first
+    assert_equal 0, Email.records.length
+    assert_equal 0, Net::SMTP.reset_called, 'Reset connection on SyntaxError'
 
-  def test_deliver
-    email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
+    assert_equal '', out
+    assert_equal &quot;sent email 00000000001 from from to to: \&quot;queued\&quot;\n&quot;, strip_log_prefix(err)
+  end
 
-    out, err = util_capture do
+  def test_log_header_setting
+    email = Email.create :mail =&gt; &quot;Mailer: JunkMail 1.0\r\nX-Track: 7890\r\n\r\nbody&quot;, :to =&gt; 'to', :from =&gt; 'from'
+    @sm.log_header = 'X-Track'
+    out, err = capture_io do
       @sm.deliver [email]
     end
 
     assert_equal 1, Net::SMTP.deliveries.length
-    assert_equal ['body', 'from', 'to'], Net::SMTP.deliveries.first
     assert_equal 0, Email.records.length
     assert_equal 0, Net::SMTP.reset_called, 'Reset connection on SyntaxError'
 
     assert_equal '', out
-    assert err.index(&quot;sent email 00000000001 from from to to: \&quot;queued\&quot;\n&quot;)
+    assert_equal &quot;sent email 00000000001 [7890] from from to to: \&quot;queued\&quot;\n&quot;, strip_log_prefix(err)
+  end
+
+  def test_deliver_not_called_when_no_emails
+    sm = ActionMailer::ARSendmail.new({:Once =&gt; true})
+    sm.expects(:deliver).never
+    sm.run
   end
 
   def test_deliver_auth_error
@@ -428,7 +326,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 
     email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
 
-    out, err = util_capture do
+    out, err = capture_io do
       @sm.deliver [email]
     end
 
@@ -440,21 +338,20 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     assert_equal [60], @sm.slept
 
     assert_equal '', out
-    assert err.index(&quot;authentication error, retrying: try again\n&quot;)
+    assert_equal &quot;authentication error, retrying: try again\n&quot;, strip_log_prefix(err)
   end
 
   def test_deliver_auth_error_recover
     email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
     @sm.failed_auth_count = 1
 
-    out, err = util_capture do @sm.deliver [email] end
+    out, err = capture_io do @sm.deliver [email] end
 
     assert_equal 0, @sm.failed_auth_count
     assert_equal 1, Net::SMTP.deliveries.length
   end
 
   def test_deliver_auth_error_twice
-    email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
     Net::SMTP.on_start do
       e = Net::SMTPAuthenticationError.new 'try again'
       e.set_backtrace %w[one two three]
@@ -463,30 +360,16 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 
     @sm.failed_auth_count = 1
 
-    out, err = util_capture do
-      assert_raise Net::SMTPAuthenticationError do
-        @sm.deliver [email]
+    out, err = capture_io do
+      assert_raises Net::SMTPAuthenticationError do
+        @sm.deliver []
       end
     end
 
     assert_equal 2, @sm.failed_auth_count
-    assert err.index(&quot;authentication error, giving up: try again\n&quot;)
+    assert_equal &quot;authentication error, giving up: try again\n&quot;, strip_log_prefix(err)
   end
 
-  def test_deliver_no_auth_without_emails
-    Net::SMTP.on_start do
-      e = Net::SMTPAuthenticationError.new 'no throw'
-      e.set_backtrace %w[one two three]
-      raise e
-    end
-
-    out, err = util_capture do
-      @sm.deliver []
-    end
-    assert_equal '', err, &quot;authentication attempt without any emails to send&quot;
-    assert_equal 0, Net::SMTP.deliveries.length
-  end
-  
   def test_deliver_4xx_error
     Net::SMTP.on_send_message do
       e = Net::SMTPSyntaxError.new 'try again'
@@ -498,7 +381,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 
     email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
 
-    out, err = util_capture do
+    out, err = capture_io do
       @sm.deliver [email]
     end
 
@@ -508,7 +391,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     assert_equal 1, Net::SMTP.reset_called, 'Reset connection on SyntaxError'
 
     assert_equal '', out
-    assert err.index(&quot;error sending email 1: \&quot;try again\&quot;(Net::SMTPSyntaxError):\n\tone\n\ttwo\n\tthree\n&quot;)
+    assert_equal &quot;error sending email 1: \&quot;try again\&quot;(Net::SMTPSyntaxError):\n\tone\n\ttwo\n\tthree\n&quot;, strip_log_prefix(err)
   end
 
   def test_deliver_5xx_error
@@ -522,7 +405,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 
     email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
 
-    out, err = util_capture do
+    out, err = capture_io do
       @sm.deliver [email]
     end
 
@@ -531,7 +414,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     assert_equal 1, Net::SMTP.reset_called, 'Reset connection on SyntaxError'
 
     assert_equal '', out
-    assert err.index(&quot;5xx error sending email 1, removing from queue: \&quot;unknown recipient\&quot;(Net::SMTPFatalError):\n\tone\n\ttwo\n\tthree\n&quot;)
+    assert_equal &quot;5xx error sending email 1, removing from queue: \&quot;unknown recipient\&quot;(Net::SMTPFatalError):\n\tone\n\ttwo\n\tthree\n&quot;, strip_log_prefix(err)
   end
 
   def test_deliver_errno_epipe
@@ -543,7 +426,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 
     email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
 
-    out, err = util_capture do
+    out, err = capture_io do
       @sm.deliver [email]
     end
 
@@ -567,7 +450,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 
     email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
 
-    out, err = util_capture do
+    out, err = capture_io do
       @sm.deliver [email]
     end
 
@@ -578,7 +461,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     assert_equal [60], @sm.slept
 
     assert_equal '', out
-    assert err.index(&quot;server too busy, sleeping 60 seconds\n&quot;)
+    assert_equal &quot;server too busy, sleeping 60 seconds\n&quot;, strip_log_prefix(err)
   end
 
   def test_deliver_syntax_error
@@ -594,7 +477,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     email1 = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
     email2 = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
 
-    out, err = util_capture do
+    out, err = capture_io do
       @sm.deliver [email1, email2]
     end
 
@@ -604,9 +487,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     assert_operator now, :&lt;=, Email.records.first.last_send_attempt
 
     assert_equal '', out
-
-    assert err.index(&quot;error sending email 1: \&quot;blah blah blah\&quot;(Net::SMTPSyntaxError):\n\tone\n\ttwo\n\tthree\n&quot;)
-    assert err.index(&quot;sent email 00000000002 from from to to: \&quot;queued\&quot;\n&quot;)
+    assert_equal &quot;error sending email 1: \&quot;blah blah blah\&quot;(Net::SMTPSyntaxError):\n\tone\n\ttwo\n\tthree\nsent email 00000000002 from from to to: \&quot;queued\&quot;\n&quot;, strip_log_prefix(err)
   end
 
   def test_deliver_timeout
@@ -620,7 +501,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 
     email = Email.create :mail =&gt; 'body', :to =&gt; 'to', :from =&gt; 'from'
 
-    out, err = util_capture do
+    out, err = capture_io do
       @sm.deliver [email]
     end
 
@@ -630,26 +511,26 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
     assert_equal 1, Net::SMTP.reset_called, 'Reset connection on Timeout'
 
     assert_equal '', out
-    assert err.index(&quot;error sending email 1: \&quot;timed out\&quot;(Timeout::Error):\n\tone\n\ttwo\n\tthree\n&quot;)
+    assert_equal &quot;error sending email 1: \&quot;timed out\&quot;(Timeout::Error):\n\tone\n\ttwo\n\tthree\n&quot;, strip_log_prefix(err)
   end
 
   def test_do_exit
-    out, err = util_capture do
-      assert_raise SystemExit do
+    out, err = capture_io do
+      assert_raises SystemExit do
         @sm.do_exit
       end
     end
 
     assert_equal '', out
-    assert err.index(&quot;caught signal, shutting down\n&quot;)
+    assert_equal &quot;caught signal, shutting down\n&quot;, strip_log_prefix(err)
   end
 
   def test_log
-    out, err = util_capture do
+    out, err = capture_io do
       @sm.log 'hi'
     end
 
-    assert err.index(&quot;hi\n&quot;)
+    assert_equal &quot;hi\n&quot;, strip_log_prefix(err)
   end
 
   def test_find_emails
@@ -668,14 +549,14 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
 
     found_emails = []
 
-    out, err = util_capture do
+    out, err = capture_io do
       found_emails = @sm.find_emails
     end
 
     assert_equal emails, found_emails
 
     assert_equal '', out
-    assert err.index(&quot;found 3 emails to send\n&quot;)
+    assert_equal &quot;found 3 emails to send\n&quot;, strip_log_prefix(err)
   end
 
   def test_smtp_settings
@@ -689,4 +570,3 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
   end
 
 end
-</diff>
      <filename>test/test_arsendmail.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>Manifest.txt</filename>
    </removed>
    <removed>
      <filename>README.txt</filename>
    </removed>
    <removed>
      <filename>test/action_mailer.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>fefca3700986de39c6e74664c903bc13d99c8ffe</id>
    </parent>
  </parents>
  <author>
    <name>Morten Primdahl</name>
    <email>morten@zendesk.com</email>
  </author>
  <url>http://github.com/adzap/ar_mailer/commit/85f8fba9eeb2c8caf7ca3197be2f213794b69d4e</url>
  <id>85f8fba9eeb2c8caf7ca3197be2f213794b69d4e</id>
  <committed-date>2009-08-31T05:21:05-07:00</committed-date>
  <authored-date>2009-08-31T05:21:05-07:00</authored-date>
  <message>Updated to Adzaps latest version and using a less intrusive mechanism for logging context headers</message>
  <tree>f2e0f09be21d4839de1684e4893b7a939711b546</tree>
  <committer>
    <name>Morten Primdahl</name>
    <email>morten@zendesk.com</email>
  </committer>
</commit>
