flipstone-ar_mailer 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +158 -0
- data/LICENSE.txt +28 -0
- data/README.rdoc +137 -0
- data/Rakefile +76 -0
- data/bin/ar_sendmail +6 -0
- data/generators/ar_mailer/ar_mailer_generator.rb +25 -0
- data/generators/ar_mailer/templates/migration.rb +15 -0
- data/generators/ar_mailer/templates/model.rb +2 -0
- data/lib/ar_mailer/active_record.rb +43 -0
- data/lib/ar_mailer/ar_sendmail.rb +484 -0
- data/lib/flipstone-ar_mailer.rb +1 -0
- data/lib/smtp_tls.rb +105 -0
- data/share/bsd/ar_sendmail +30 -0
- data/share/linux/ar_sendmail +78 -0
- data/share/linux/ar_sendmail.conf +30 -0
- data/test/resources/action_mailer.rb +218 -0
- data/test/test_armailer.rb +58 -0
- data/test/test_arsendmail.rb +542 -0
- data/test/test_helper.rb +11 -0
- metadata +116 -0
data/History.txt
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
= 2.1.8
|
2
|
+
|
3
|
+
* Bugs fixed
|
4
|
+
* Fix BCC addresses being visible to all recipients (laserlemon)
|
5
|
+
|
6
|
+
= 2.1.7
|
7
|
+
|
8
|
+
* Miscellaneous Updates
|
9
|
+
* Added adzap-ar_mailer file to end the need for the config.gem :lib option
|
10
|
+
|
11
|
+
* Bugs fixed
|
12
|
+
* Fix from address being set as address header object.
|
13
|
+
|
14
|
+
= 2.1.6
|
15
|
+
|
16
|
+
* Miscellaneous Updates
|
17
|
+
* Use return-path as from address if set, as per default ActionMailer::Base SMTP delivery (Dustin Tinney)
|
18
|
+
* Always wait full delay between deliveries (cyu)
|
19
|
+
|
20
|
+
* Bugs fixed
|
21
|
+
* Non-zero return code returned in init.d script (hennk)
|
22
|
+
* Use updated Timeout error class (hennk)
|
23
|
+
|
24
|
+
= 2.1.5
|
25
|
+
|
26
|
+
* Bugs fixed
|
27
|
+
* Load ar_mailer after environment to fix issue with lazy loading of ActionMailer in Rails 2.3
|
28
|
+
|
29
|
+
= 2.1.4
|
30
|
+
|
31
|
+
* Bugs fixed
|
32
|
+
* Explicitly require ar_mailer in ar_sendmail because its not getting loaded by the Rails environment for some reason
|
33
|
+
|
34
|
+
= 2.1.3
|
35
|
+
|
36
|
+
* Tests now pass on gem install
|
37
|
+
* Removed deprecated ActionMailer::ARMailer class
|
38
|
+
* Bugs fixed
|
39
|
+
* 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.
|
40
|
+
|
41
|
+
= 2.1.2
|
42
|
+
|
43
|
+
* Bugs fixed
|
44
|
+
* Require ar_mailer in ar_sendmail since the change to remove TableName and use email_class
|
45
|
+
|
46
|
+
= 2.1.1
|
47
|
+
|
48
|
+
* Force gem rebuild
|
49
|
+
|
50
|
+
= 2.1.0
|
51
|
+
|
52
|
+
* Switched to using a Rails generator for migration and model files. The ar_sendmail options have been removed.
|
53
|
+
|
54
|
+
= 2.0.2
|
55
|
+
|
56
|
+
* Removed TableName option from ar_sendmail options as its redundant. The Rails environment gets loaded so the settings for email class also get loaded
|
57
|
+
* Bugs fixed
|
58
|
+
* Email class reloading issue in development mode causing AR email class defaults to be lost when cached
|
59
|
+
|
60
|
+
= 2.0.1
|
61
|
+
|
62
|
+
* Added option to use smtp setting of :tls => false to disable TLS auto start in Ruby 1.8.7+
|
63
|
+
* Removed some cruft which can be handled by ActiveSupport
|
64
|
+
|
65
|
+
= 2.0.0
|
66
|
+
|
67
|
+
* 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.
|
68
|
+
* Only include SMTP TLS patch if Ruby version < 1.8.7 as it has an alternative. Changes based on Calvin Yu's [cyu] fork.
|
69
|
+
* Renamed default migration name to the modern Rails default
|
70
|
+
* Only authenticate if emails waiting to be sent
|
71
|
+
* Added --version switch to ar_sendmail binary
|
72
|
+
* Created a lighthouse account for this project (adzap fork only). See README.
|
73
|
+
|
74
|
+
= 1.4.4
|
75
|
+
|
76
|
+
* Exit init.d script with message if no mailers defined.
|
77
|
+
|
78
|
+
= 1.4.3
|
79
|
+
|
80
|
+
* Bugs fixed
|
81
|
+
* Replaced mistaken call to log when removing pid file artifact for
|
82
|
+
non-running daemon
|
83
|
+
|
84
|
+
= 1.4.2
|
85
|
+
|
86
|
+
* New Features
|
87
|
+
* Added Ruby based linux init.d script for handling daemon startup using yaml
|
88
|
+
config file. See files share/linux/ar_sendmail and ar_sendmail.conf
|
89
|
+
* Bugs fixed
|
90
|
+
* Proper handling for relative and absolute paths for the pid file
|
91
|
+
* Removed hoe dependency since we need the explicit gemspec file for github and
|
92
|
+
not deploying to RubyForge its not as useful.
|
93
|
+
* Moved old BSD rc.d script to share/bsd folder
|
94
|
+
* Updated README with github gem install, docs and init script info
|
95
|
+
|
96
|
+
= 1.4.1
|
97
|
+
|
98
|
+
* Bugs fixed
|
99
|
+
* Daemon failed on startup fixed with expanding full path of pid file
|
100
|
+
|
101
|
+
= 1.4.0
|
102
|
+
|
103
|
+
* Forked gem and published on GitHub (gem sources -a http://gems.github.com)
|
104
|
+
* New Features
|
105
|
+
* Added pid file creation on daemonize with command line option to specify pid filename [Dylan Egan]
|
106
|
+
|
107
|
+
= 1.3.1
|
108
|
+
|
109
|
+
* Fix bug #12530, gmail causes SSL errors. Submitted by Kyle Maxwell
|
110
|
+
and Alex Ostleitner.
|
111
|
+
* Try ActionMailer::Base::server_settings then ::smtp_settings. Fixes
|
112
|
+
bug #12516. Submitted by Alex Ostleitner.
|
113
|
+
|
114
|
+
= 1.3.0
|
115
|
+
|
116
|
+
* New Features
|
117
|
+
* Added automatic mail queue cleanup.
|
118
|
+
* MAY CAUSE LOSS OF DATA. If you haven't run ar_sendmail within
|
119
|
+
the expiry time, set it to 0.
|
120
|
+
* Bugs fixed
|
121
|
+
* Authentication errors are now handled by retrying once.
|
122
|
+
|
123
|
+
= 1.2.0
|
124
|
+
|
125
|
+
* Bugs fixed
|
126
|
+
* Handle SMTPServerBusy by backing off @delay seconds then re-queueing
|
127
|
+
* Allow email delivery class to be set in ARMailer.
|
128
|
+
* ar_sendmail --mailq works with --table-name now.
|
129
|
+
* Miscellaneous Updates
|
130
|
+
* Added documentation to require 'action_mailer/ar_mailer' in
|
131
|
+
instructions.
|
132
|
+
* Moved to ZSS p4 repository
|
133
|
+
* Supports TLS now. Requested by Dave Thomas. smtp_tls.rb from Kyle
|
134
|
+
Maxwell & etc.
|
135
|
+
|
136
|
+
= 1.1.0
|
137
|
+
|
138
|
+
* Features
|
139
|
+
* Added --chdir to set rails directory
|
140
|
+
* Added --environment to set RAILS_ENV
|
141
|
+
* Exits cleanly on TERM or INT signals
|
142
|
+
* Added FreeBSD rc.d script
|
143
|
+
* Exceptions during SMTP sending are now logged
|
144
|
+
* No longer waits if sending email took too long
|
145
|
+
* Bugs fixed
|
146
|
+
* Fixed last send attempt in --mailq
|
147
|
+
* Better SMTP error handling
|
148
|
+
* Messages are removed from the queue on 5xx errors
|
149
|
+
* Added Net::SMTP.reset to avoid needing to recreate the connection
|
150
|
+
|
151
|
+
= 1.0.1
|
152
|
+
|
153
|
+
* Bugs fixed
|
154
|
+
* From and to of email destination were swapped
|
155
|
+
|
156
|
+
= 1.0.0
|
157
|
+
|
158
|
+
* Birthday
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Original code copyright 2006, 2007, Eric Hodel, The Robot Co-op. All
|
2
|
+
rights reserved. Some code under other license, see individual files
|
3
|
+
for details.
|
4
|
+
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
6
|
+
modification, are permitted provided that the following conditions
|
7
|
+
are met:
|
8
|
+
|
9
|
+
1. Redistributions of source code must retain the above copyright
|
10
|
+
notice, this list of conditions and the following disclaimer.
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright
|
12
|
+
notice, this list of conditions and the following disclaimer in the
|
13
|
+
documentation and/or other materials provided with the distribution.
|
14
|
+
3. Neither the names of the authors nor the names of their contributors
|
15
|
+
may be used to endorse or promote products derived from this software
|
16
|
+
without specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
19
|
+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
20
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
21
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
|
22
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23
|
+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
24
|
+
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
25
|
+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
26
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
27
|
+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
28
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
= ar_mailer
|
2
|
+
|
3
|
+
A two-phase delivery agent for ActionMailer
|
4
|
+
|
5
|
+
Rubyforge Project:
|
6
|
+
|
7
|
+
http://rubyforge.org/projects/seattlerb
|
8
|
+
|
9
|
+
Documentation:
|
10
|
+
|
11
|
+
http://seattlerb.org/ar_mailer
|
12
|
+
|
13
|
+
and for forked additions
|
14
|
+
|
15
|
+
http://github.com/adzap/ar_mailer/wikis
|
16
|
+
|
17
|
+
Bugs:
|
18
|
+
|
19
|
+
http://adzap.lighthouseapp.com/projects/26997-ar_mailer
|
20
|
+
|
21
|
+
== About
|
22
|
+
|
23
|
+
Even delivering email to the local machine may take too long when you have to
|
24
|
+
send hundreds of messages. ar_mailer allows you to store messages into the
|
25
|
+
database for later delivery by a separate process, ar_sendmail.
|
26
|
+
|
27
|
+
== Installing ar_mailer (forked)
|
28
|
+
|
29
|
+
Before installing you will need to make sure the original gem is uninstalled as they can't coexist:
|
30
|
+
|
31
|
+
$ sudo gem uninstall ar_mailer
|
32
|
+
|
33
|
+
Then
|
34
|
+
|
35
|
+
$ sudo gem install adzap-ar_mailer
|
36
|
+
|
37
|
+
For Rails >= 2.1, in your environment.rb:
|
38
|
+
|
39
|
+
config.gem "adzap-ar_mailer", :lib => 'action_mailer/ar_mailer'
|
40
|
+
|
41
|
+
# or since version 2.1.7 of this gem you can now just do
|
42
|
+
|
43
|
+
config.gem "adzap-ar_mailer"
|
44
|
+
|
45
|
+
For Rails 2.0, in an initializer file:
|
46
|
+
|
47
|
+
require 'action_mailer/ar_mailer'
|
48
|
+
|
49
|
+
== Usage
|
50
|
+
|
51
|
+
Go to your Rails project:
|
52
|
+
|
53
|
+
$ cd your_rails_project
|
54
|
+
|
55
|
+
Create the migration and model:
|
56
|
+
|
57
|
+
This shows the options which are only the model name, which defaults to Email
|
58
|
+
|
59
|
+
./script/generate ar_mailer -h
|
60
|
+
|
61
|
+
Then run with defaults
|
62
|
+
|
63
|
+
./script/generate ar_mailer
|
64
|
+
|
65
|
+
Or specify a custom model name
|
66
|
+
|
67
|
+
./script/generate ar_mailer Newsletter
|
68
|
+
|
69
|
+
See Alternate Mail Storage if you use a custom model name
|
70
|
+
|
71
|
+
In your mailer class methods you must be sure to set the From address for your emails.
|
72
|
+
Something like:
|
73
|
+
|
74
|
+
def list_send(recipient)
|
75
|
+
from 'no_reply@example.com'
|
76
|
+
# ...
|
77
|
+
|
78
|
+
Edit config/environments/production.rb and set the delivery method:
|
79
|
+
|
80
|
+
config.action_mailer.delivery_method = :activerecord
|
81
|
+
|
82
|
+
Or if you need to, you can set each mailer class delivery method individually:
|
83
|
+
|
84
|
+
class MyMailer < ActionMailer::Base
|
85
|
+
self.delivery_method = :activerecord
|
86
|
+
end
|
87
|
+
|
88
|
+
This can be useful when using plugins like ExceptionNotification. Where it
|
89
|
+
might be foolish to tie the sending of the email alert to the database when the
|
90
|
+
database might be causing the exception being raised. In this instance you could
|
91
|
+
override ExceptionNofitier delivery method to be smtp or set the other
|
92
|
+
mailer classes to use ARMailer explicitly.
|
93
|
+
|
94
|
+
Then to run it:
|
95
|
+
|
96
|
+
$ ar_sendmail
|
97
|
+
|
98
|
+
You can also run it from cron with -o, or as a daemon with -d.
|
99
|
+
|
100
|
+
See <tt>ar_sendmail -h</tt> for full details.
|
101
|
+
|
102
|
+
=== Alternate Mail Storage
|
103
|
+
|
104
|
+
By default ar_mailer assumes you are using an ActiveRecord model called
|
105
|
+
Email to store the emails created before sending. If you want to change
|
106
|
+
this you alter it in an intializer like so:
|
107
|
+
|
108
|
+
ActionMailer::Base.email_class = Newsletter
|
109
|
+
|
110
|
+
=== A Word on TLS
|
111
|
+
|
112
|
+
If you are using Ruby >= 1.8.7, TLS will be enabled automatically if your
|
113
|
+
SMTP server supports it. If you do not want it to automatically enabled then
|
114
|
+
set the :tls option to false in your smtp_settings.
|
115
|
+
|
116
|
+
If you are on Ruby <= 1.8.6, then the TLS patch included in this plugin will
|
117
|
+
be loaded, so you don't need another TLS plugin to add the capability. This
|
118
|
+
patch allows you to explicit set if the server supports TLS by setting the
|
119
|
+
:tls option to true in your smtp_settings.
|
120
|
+
|
121
|
+
=== Help
|
122
|
+
|
123
|
+
See ar_sendmail -h for options to ar_sendmail.
|
124
|
+
|
125
|
+
NOTE: You may need to delete an smtp_tls.rb file if you have one lying
|
126
|
+
around. ar_mailer supplies it own.
|
127
|
+
|
128
|
+
== Run as a service (init.d/rc.d scripts)
|
129
|
+
|
130
|
+
For Linux both script and demo config files are in share/linux.
|
131
|
+
See ar_sendmail.conf for setting up your config. Copy the ar_sendmail file
|
132
|
+
to /etc/init.d/ and make it executable. Then for Debian based distros run
|
133
|
+
'sudo update-rc.d ar_sendmail defaults' and it should work. Make sure you have
|
134
|
+
the config file /etc/ar_sendmail.conf in place before starting.
|
135
|
+
|
136
|
+
For FreeBSD or NetBSD script is share/bsd/ar_sendmail. This is old and does not
|
137
|
+
support the config file unless someone wants to submit a patch.
|
data/Rakefile
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
|
6
|
+
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/lib'))
|
7
|
+
|
8
|
+
require './lib/ar_mailer/ar_sendmail'
|
9
|
+
|
10
|
+
ar_mailer_gemspec = Gem::Specification.new do |s|
|
11
|
+
s.name = %q{flipstone-ar_mailer}
|
12
|
+
s.version = ArMailer::ARSendmail::VERSION
|
13
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
14
|
+
s.authors = ["Eric Hodel", "Adam Meehan"]
|
15
|
+
s.default_executable = %q{ar_sendmail}
|
16
|
+
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.}
|
17
|
+
s.email = %q{david@flipstone.com}
|
18
|
+
s.executables = ["ar_sendmail"]
|
19
|
+
s.extra_rdoc_files = ["History.txt", "LICENSE.txt", "README.rdoc"]
|
20
|
+
s.files = [
|
21
|
+
"History.txt",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"bin/ar_sendmail",
|
26
|
+
"generators/ar_mailer/ar_mailer_generator.rb",
|
27
|
+
"generators/ar_mailer/templates/migration.rb",
|
28
|
+
"generators/ar_mailer/templates/model.rb",
|
29
|
+
"lib/flipstone-ar_mailer.rb",
|
30
|
+
"lib/ar_mailer/active_record.rb",
|
31
|
+
"lib/ar_mailer/ar_sendmail.rb",
|
32
|
+
"lib/smtp_tls.rb",
|
33
|
+
"share/bsd/ar_sendmail",
|
34
|
+
"share/linux/ar_sendmail",
|
35
|
+
"share/linux/ar_sendmail.conf",
|
36
|
+
"test/resources/action_mailer.rb",
|
37
|
+
"test/test_armailer.rb",
|
38
|
+
"test/test_arsendmail.rb",
|
39
|
+
"test/test_helper.rb"
|
40
|
+
]
|
41
|
+
s.has_rdoc = true
|
42
|
+
s.homepage = %q{http://github.com/flipstone/ar_mailer}
|
43
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubyforge_project = %q{seattlerb}
|
46
|
+
s.summary = %q{A two-phase delivery agent for ActionMailer}
|
47
|
+
s.test_files = ["test/test_armailer.rb", "test/test_arsendmail.rb"]
|
48
|
+
s.add_development_dependency "minitest", ">= 1.5.0"
|
49
|
+
s.add_development_dependency "mocha", ">= 0.9.8"
|
50
|
+
end
|
51
|
+
|
52
|
+
Rake::GemPackageTask.new(ar_mailer_gemspec) do |pkg|
|
53
|
+
pkg.gem_spec = ar_mailer_gemspec
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Update ar_mailer.gemspec"
|
57
|
+
task :make_spec do
|
58
|
+
File.open("flipstone-ar_mailer.gemspec", "w") do |f|
|
59
|
+
f.puts(ar_mailer_gemspec.to_ruby)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Build packages and install"
|
64
|
+
task :install => :package do
|
65
|
+
sh %{sudo gem install --local --test pkg/ar_mailer-#{ActionMailer::ARSendmail::VERSION}}
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'Default: run unit tests.'
|
69
|
+
task :default => :test
|
70
|
+
|
71
|
+
desc 'Test the ar_mailer gem.'
|
72
|
+
Rake::TestTask.new(:test) do |t|
|
73
|
+
t.libs << 'lib' << 'test'
|
74
|
+
t.test_files = FileList['test/**/test_*.rb'].exclude("test/test_helper.rb")
|
75
|
+
t.verbose = true
|
76
|
+
end
|
data/bin/ar_sendmail
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class ArMailerGenerator < Rails::Generator::NamedBase
|
2
|
+
|
3
|
+
def initialize(runtime_args, runtime_options = {})
|
4
|
+
runtime_args.unshift('Email') if runtime_args.empty?
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def manifest
|
9
|
+
record do |m|
|
10
|
+
m.class_collisions class_name
|
11
|
+
|
12
|
+
m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
|
13
|
+
|
14
|
+
m.migration_template 'migration.rb', 'db/migrate', :assigns => {
|
15
|
+
:migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
|
16
|
+
}, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
def banner
|
22
|
+
"Usage: #{$0} #{spec.name} EmailModelName (default: Email)"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class <%= migration_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :<%= table_name %> do |t|
|
4
|
+
t.column :from, :string
|
5
|
+
t.column :to, :string
|
6
|
+
t.column :last_send_attempt, :integer, :default => 0
|
7
|
+
t.column :mail, :text
|
8
|
+
t.column :created_on, :datetime
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :<%= table_name %>
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
##
|
2
|
+
# Adds sending email through an ActiveRecord table as a delivery method for
|
3
|
+
# ActionMailer.
|
4
|
+
#
|
5
|
+
module ArMailer
|
6
|
+
class ActiveRecord
|
7
|
+
|
8
|
+
##
|
9
|
+
# Set the email class for deliveries. Handle class reloading issues which prevents caching the email class.
|
10
|
+
#
|
11
|
+
@@email_class_name = 'Email'
|
12
|
+
|
13
|
+
def self.email_class=(klass)
|
14
|
+
@@email_class_name = klass.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.email_class
|
18
|
+
@@email_class_name.constantize
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Adds +mail+ to the Email table. Only the first From address for +mail+ is
|
23
|
+
# used.
|
24
|
+
|
25
|
+
def deliver!(mail)
|
26
|
+
destinations = mail.destinations
|
27
|
+
sender = (mail['return-path'] && mail['return-path'].spec) || mail.from.first
|
28
|
+
destinations.each do |destination|
|
29
|
+
(mail.email_class || self.class.email_class).create :mail => mail.encoded, :to => destination, :from => sender
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
module EmailClassAttribute
|
36
|
+
attr_accessor :email_class
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
ActionMailer::Base.add_delivery_method :activerecord, ArMailer::ActiveRecord
|
41
|
+
ActionMailer::Base.delivery_method = :activerecord
|
42
|
+
Mail::Message.send :include, ArMailer::EmailClassAttribute
|
43
|
+
|