Permalink
Browse files

Move RailsRemoteControl to p4.

Move ar_sendmail to p4.
Move cached_model to p4.

[git-p4: depot-paths = "//src/ar_mailer/dev/": change = 2835]
  • Loading branch information...
0 parents commit 33c014b35612f2f91246b9cf131cb793df0da13a @drbrain drbrain committed Jan 2, 2007
Showing with 1,490 additions and 0 deletions.
  1. +37 −0 CHANGES
  2. +26 −0 LICENSE
  3. +12 −0 Manifest.txt
  4. +30 −0 README
  5. +67 −0 Rakefile
  6. +6 −0 bin/ar_sendmail
  7. +67 −0 lib/action_mailer/ar_mailer.rb
  8. +445 −0 lib/action_mailer/ar_sendmail.rb
  9. +30 −0 share/ar_sendmail
  10. +158 −0 test/action_mailer.rb
  11. +39 −0 test/test_armailer.rb
  12. +573 −0 test/test_arsendmail.rb
37 CHANGES
@@ -0,0 +1,37 @@
+= trunk
+
+== Features
+
+* Moved to p4
+
+== Bugs fixed
+
+* Handle SMTPServerBusy by backing off @delay seconds then re-queueing
+
+= 1.1.0
+
+== Features
+
+* Added --chdir to set rails directory
+* Added --environment to set RAILS_ENV
+* Exits cleanly on TERM or INT signals
+* Added FreeBSD rc.d script
+* Exceptions during SMTP sending are now logged
+* No longer waits if sending email took too long
+
+== Bugs fixed
+
+* Fixed last send attempt in --mailq
+* Better SMTP error handling
+ * Messages are removed from the queue on 5xx errors
+ * Added Net::SMTP.reset to avoid needing to recreate the connection
+
+= 1.0.1
+
+== Bugs fixed
+
+* From and to of email destination were swapped
+
+= 1.0.0
+
+* Birthday
26 LICENSE
@@ -0,0 +1,26 @@
+Copyright 2006, Eric Hodel, The Robot Co-op. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. Neither the names of the authors nor the names of their contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
+OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,12 @@
+CHANGES
+LICENSE
+Manifest.txt
+README
+Rakefile
+bin/ar_sendmail
+lib/action_mailer/ar_mailer.rb
+lib/action_mailer/ar_sendmail.rb
+share/ar_sendmail
+test/action_mailer.rb
+test/test_armailer.rb
+test/test_arsendmail.rb
30 README
@@ -0,0 +1,30 @@
+= ar_mailer
+
+Rubyforge Project:
+
+http://rubyforge.org/projects/rctools
+
+Documentation:
+
+http://dev.robotcoop.com/Tools/ar_mailer
+
+== About
+
+Even deliviring 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.
+
+== Installing ar_mailer
+
+Just install the gem:
+
+ $ sudo gem install ar_mailer
+
+See ActionMailer::ARMailer for instructions on converting to ARMailer.
+
+See ar_sendmail -h for options to ar_sendmail.
+
+=== ar_sendmail on FreeBSD or NetBSD
+
+An rc.d script is included in share/ar_sendmail.
+
@@ -0,0 +1,67 @@
+require 'rubygems'
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+require 'rake/gempackagetask'
+
+$VERBOSE = nil
+
+spec = Gem::Specification.new do |s|
+ s.name = 'ar_mailer'
+ s.version = '1.1.1'
+ s.summary = 'A two-phase deliver agent for ActionMailer'
+ s.description = 'Queues emails from ActionMailer in the database and uses a separate process to send them. Reduces sending overhead when sending hundreds of emails.'
+ s.author = 'Eric Hodel'
+ s.email = 'eric@robotcoop.com'
+
+ s.has_rdoc = true
+ s.files = File.read('Manifest.txt').split($/)
+ s.require_path = 'lib'
+
+ s.executables = ['ar_sendmail']
+end
+
+desc 'Run tests'
+task :default => [ :test ]
+
+Rake::TestTask.new('test') do |t|
+ t.libs << 'test'
+ t.pattern = 'test/test_*.rb'
+ t.verbose = true
+end
+
+desc 'Update Manifest.txt'
+task :update_manifest do
+ sh "find . -type f | sed -e 's%./%%' | egrep -v 'svn|swp|~' | egrep -v '^(doc|pkg)/' | sort > Manifest.txt"
+end
+
+desc 'Generate RDoc'
+Rake::RDocTask.new :rdoc do |rd|
+ rd.rdoc_dir = 'doc'
+ rd.rdoc_files.add 'lib', 'README', 'LICENSE', 'CHANGES'
+ rd.main = 'README'
+ rd.options << '-d' if `which dot` =~ /\/dot/
+ rd.options << '-t ar_mailer'
+end
+
+desc 'Generate RDoc for dev.robotcoop.com'
+Rake::RDocTask.new :dev_rdoc do |rd|
+ rd.rdoc_dir = '../../../www/trunk/dev/html/Tools/ar_mailer'
+ rd.rdoc_files.add 'lib', 'README', 'LICENSE', 'CHANGES'
+ rd.main = 'README'
+ rd.options << '-d' if `which dot` =~ /\/dot/
+ rd.options << '-t ar_mailer'
+end
+
+desc 'Build Gem'
+Rake::GemPackageTask.new spec do |pkg|
+ pkg.need_tar = true
+end
+
+desc 'Clean up'
+task :clean => [ :clobber_rdoc, :clobber_package ]
+
+desc 'Clean up'
+task :clobber => [ :clean ]
+
+# vim: syntax=Ruby
@@ -0,0 +1,6 @@
+#!/usr/local/bin/ruby
+
+require 'action_mailer/ar_sendmail'
+
+ActionMailer::ARSendmail.run
+
@@ -0,0 +1,67 @@
+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 < ActionMailer::Base
+# +class Emailer < ActionMailer::ARMailer
+#
+# def comment_notification(comment)
+# from comment.author.email
+#
+# 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 <tt>ar_sendmail -h</tt> for full details.
+
+class ActionMailer::ARMailer < ActionMailer::Base
+
+ ##
+ # 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|
+ Email.create :mail => mail.encoded,
+ :to => destination,
+ :from => mail.from.first
+ end
+ end
+
+end
+
Oops, something went wrong.

0 comments on commit 33c014b

Please sign in to comment.