brunoaalves-ar_mailer 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +94 -0
- data/LICENSE.txt +28 -0
- data/Manifest.txt +15 -0
- data/README.rdoc +124 -0
- data/Rakefile +58 -0
- data/bin/ar_sendmail +6 -0
- data/lib/action_mailer/ar_mailer.rb +46 -0
- data/lib/action_mailer/ar_sendmail.rb +567 -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/action_mailer.rb +197 -0
- data/test/test_armailer.rb +51 -0
- data/test/test_arsendmail.rb +666 -0
- metadata +73 -0
data/History.txt
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
= 2.0.0
|
2
|
+
|
3
|
+
* 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.
|
4
|
+
* Only include SMTP TLS patch if Ruby version < 1.8.7 as it has an alternative. Changes based on Calvin Yu's [cyu] fork.
|
5
|
+
* Renamed default migration name to the modern Rails default
|
6
|
+
* Only authenticate if emails waiting to be sent
|
7
|
+
* Added --version switch to ar_sendmail binary
|
8
|
+
* Created a lighthouse account for this project (adzap fork only). See README.
|
9
|
+
|
10
|
+
= 1.4.4
|
11
|
+
|
12
|
+
* Exit init.d script with message if no mailers defined.
|
13
|
+
|
14
|
+
= 1.4.3
|
15
|
+
|
16
|
+
* Bugs fixed
|
17
|
+
* Replaced mistaken call to log when removing pid file artifact for
|
18
|
+
non-running daemon
|
19
|
+
|
20
|
+
= 1.4.2
|
21
|
+
|
22
|
+
* New Features
|
23
|
+
* Added Ruby based linux init.d script for handling daemon startup using yaml
|
24
|
+
config file. See files share/linux/ar_sendmail and ar_sendmail.conf
|
25
|
+
* Bugs fixed
|
26
|
+
* Proper handling for relative and absolute paths for the pid file
|
27
|
+
* Removed hoe dependency since we need the explicit gemspec file for github and
|
28
|
+
not deploying to RubyForge its not as useful.
|
29
|
+
* Moved old BSD rc.d script to share/bsd folder
|
30
|
+
* Updated README with github gem install, docs and init script info
|
31
|
+
|
32
|
+
= 1.4.1
|
33
|
+
|
34
|
+
* Bugs fixed
|
35
|
+
* Daemon failed on startup fixed with expanding full path of pid file
|
36
|
+
|
37
|
+
= 1.4.0
|
38
|
+
|
39
|
+
* Forked gem and published on GitHub (gem sources -a http://gems.github.com)
|
40
|
+
* New Features
|
41
|
+
* Added pid file creation on daemonize with command line option to specify pid filename [Dylan Egan]
|
42
|
+
|
43
|
+
= 1.3.1
|
44
|
+
|
45
|
+
* Fix bug #12530, gmail causes SSL errors. Submitted by Kyle Maxwell
|
46
|
+
and Alex Ostleitner.
|
47
|
+
* Try ActionMailer::Base::server_settings then ::smtp_settings. Fixes
|
48
|
+
bug #12516. Submitted by Alex Ostleitner.
|
49
|
+
|
50
|
+
= 1.3.0
|
51
|
+
|
52
|
+
* New Features
|
53
|
+
* Added automatic mail queue cleanup.
|
54
|
+
* MAY CAUSE LOSS OF DATA. If you haven't run ar_sendmail within
|
55
|
+
the expiry time, set it to 0.
|
56
|
+
* Bugs fixed
|
57
|
+
* Authentication errors are now handled by retrying once.
|
58
|
+
|
59
|
+
= 1.2.0
|
60
|
+
|
61
|
+
* Bugs fixed
|
62
|
+
* Handle SMTPServerBusy by backing off @delay seconds then re-queueing
|
63
|
+
* Allow email delivery class to be set in ARMailer.
|
64
|
+
* ar_sendmail --mailq works with --table-name now.
|
65
|
+
* Miscellaneous Updates
|
66
|
+
* Added documentation to require 'action_mailer/ar_mailer' in
|
67
|
+
instructions.
|
68
|
+
* Moved to ZSS p4 repository
|
69
|
+
* Supports TLS now. Requested by Dave Thomas. smtp_tls.rb from Kyle
|
70
|
+
Maxwell & etc.
|
71
|
+
|
72
|
+
= 1.1.0
|
73
|
+
|
74
|
+
* Features
|
75
|
+
* Added --chdir to set rails directory
|
76
|
+
* Added --environment to set RAILS_ENV
|
77
|
+
* Exits cleanly on TERM or INT signals
|
78
|
+
* Added FreeBSD rc.d script
|
79
|
+
* Exceptions during SMTP sending are now logged
|
80
|
+
* No longer waits if sending email took too long
|
81
|
+
* Bugs fixed
|
82
|
+
* Fixed last send attempt in --mailq
|
83
|
+
* Better SMTP error handling
|
84
|
+
* Messages are removed from the queue on 5xx errors
|
85
|
+
* Added Net::SMTP.reset to avoid needing to recreate the connection
|
86
|
+
|
87
|
+
= 1.0.1
|
88
|
+
|
89
|
+
* Bugs fixed
|
90
|
+
* From and to of email destination were swapped
|
91
|
+
|
92
|
+
= 1.0.0
|
93
|
+
|
94
|
+
* 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/Manifest.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
History.txt
|
2
|
+
LICENSE.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
bin/ar_sendmail
|
7
|
+
lib/action_mailer/ar_mailer.rb
|
8
|
+
lib/action_mailer/ar_sendmail.rb
|
9
|
+
lib/smtp_tls.rb
|
10
|
+
share/bsd/ar_sendmail
|
11
|
+
share/linux/ar_sendmail
|
12
|
+
share/linux/ar_sendmail.conf
|
13
|
+
test/action_mailer.rb
|
14
|
+
test/test_armailer.rb
|
15
|
+
test/test_arsendmail.rb
|
data/README.rdoc
ADDED
@@ -0,0 +1,124 @@
|
|
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
|
+
Install the gem from GitHub gems server:
|
34
|
+
|
35
|
+
First, if you haven't already:
|
36
|
+
|
37
|
+
$ sudo gem sources -a http://gems.github.com
|
38
|
+
|
39
|
+
Then
|
40
|
+
|
41
|
+
$ sudo gem install adzap-ar_mailer
|
42
|
+
|
43
|
+
For Rails >= 2.1, in your environment.rb:
|
44
|
+
|
45
|
+
config.gem "adzap-ar_mailer", :lib => 'action_mailer/ar_mailer', :source => 'http://gems.github.com'
|
46
|
+
|
47
|
+
For Rails 2.0, in an initializer file:
|
48
|
+
|
49
|
+
require 'action_mailer/ar_mailer'
|
50
|
+
|
51
|
+
== Usage
|
52
|
+
|
53
|
+
Go to your Rails project:
|
54
|
+
|
55
|
+
$ cd your_rails_project
|
56
|
+
|
57
|
+
Create a new migration:
|
58
|
+
|
59
|
+
$ ar_sendmail --create-migration
|
60
|
+
|
61
|
+
You'll need to redirect this into a file. If you want a different name
|
62
|
+
provide the --table-name option.
|
63
|
+
|
64
|
+
Create a new model:
|
65
|
+
|
66
|
+
$ ar_sendmail --create-model
|
67
|
+
|
68
|
+
You'll need to redirect this into a file. If you want a different name
|
69
|
+
provide the --table-name option.
|
70
|
+
|
71
|
+
You'll need to be sure to set the From address for your emails. Something
|
72
|
+
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
|
+
If you want to set the ActiveRecord model that emails will be stored in,
|
105
|
+
see ActionMailer::Base.email_class=
|
106
|
+
|
107
|
+
|
108
|
+
=== Help
|
109
|
+
|
110
|
+
See ar_sendmail -h for options to ar_sendmail.
|
111
|
+
|
112
|
+
NOTE: You may need to delete an smtp_tls.rb file if you have one lying
|
113
|
+
around. ar_mailer supplies it own.
|
114
|
+
|
115
|
+
== Run as a service (init.d/rc.d scripts)
|
116
|
+
|
117
|
+
For Linux both script and demo config files are in share/linux.
|
118
|
+
See ar_sendmail.conf for setting up your config. Copy the ar_sendmail file
|
119
|
+
to /etc/init.d/ and make it executable. Then for Debian based distros run
|
120
|
+
'sudo update-rc.d ar_sendmail defaults' and it should work. Make sure you have
|
121
|
+
the config file /etc/ar_sendmail.conf in place before starting.
|
122
|
+
|
123
|
+
For FreeBSD or NetBSD script is share/bsd/ar_sendmail. This is old and does not
|
124
|
+
support the config file unless someone wants to submit a patch.
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
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/action_mailer/ar_sendmail'
|
9
|
+
|
10
|
+
ar_mailer_gemspec = Gem::Specification.new do |s|
|
11
|
+
s.name = %q{ar_mailer}
|
12
|
+
s.version = ActionMailer::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{adam.meehan@gmail.com}
|
18
|
+
s.executables = ["ar_sendmail"]
|
19
|
+
s.extra_rdoc_files = ["History.txt", "LICENSE.txt", "Manifest.txt", "README.rdoc"]
|
20
|
+
s.files = ["History.txt", "LICENSE.txt", "Manifest.txt", "README.rdoc", "Rakefile", "bin/ar_sendmail", "lib/action_mailer/ar_mailer.rb", "lib/action_mailer/ar_sendmail.rb", "lib/smtp_tls.rb", "share/bsd/ar_sendmail", "share/linux/ar_sendmail", "share/linux/ar_sendmail.conf", "test/action_mailer.rb", "test/test_armailer.rb", "test/test_arsendmail.rb"]
|
21
|
+
s.has_rdoc = true
|
22
|
+
s.homepage = %q{http://github.com/adzap/ar_mailer}
|
23
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
s.rubyforge_project = %q{seattlerb}
|
26
|
+
s.summary = %q{A two-phase delivery agent for ActionMailer}
|
27
|
+
s.test_files = ["test/test_armailer.rb", "test/test_arsendmail.rb"]
|
28
|
+
end
|
29
|
+
|
30
|
+
Rake::GemPackageTask.new(ar_mailer_gemspec) do |pkg|
|
31
|
+
pkg.gem_spec = ar_mailer_gemspec
|
32
|
+
end
|
33
|
+
|
34
|
+
namespace :gem do
|
35
|
+
namespace :spec do
|
36
|
+
desc "Update ar_mailer.gemspec"
|
37
|
+
task :generate do
|
38
|
+
File.open("ar_mailer.gemspec", "w") do |f|
|
39
|
+
f.puts(ar_mailer_gemspec.to_ruby)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Build packages and install"
|
46
|
+
task :install => :package do
|
47
|
+
sh %{sudo gem install --local pkg/ar_mailer-#{ActionMailer::ARSendmail::VERSION}}
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'Default: run unit tests.'
|
51
|
+
task :default => :test
|
52
|
+
|
53
|
+
desc 'Test the ar_mailer gem.'
|
54
|
+
Rake::TestTask.new(:test) do |t|
|
55
|
+
t.libs << 'lib' << 'test'
|
56
|
+
t.pattern = 'test/**/test_*.rb'
|
57
|
+
t.verbose = true
|
58
|
+
end
|
data/bin/ar_sendmail
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'action_mailer'
|
2
|
+
|
3
|
+
##
|
4
|
+
# Adds sending email through an ActiveRecord table as a delivery method for
|
5
|
+
# ActionMailer.
|
6
|
+
#
|
7
|
+
|
8
|
+
class ActionMailer::ARMailer < ActionMailer::Base
|
9
|
+
|
10
|
+
def self.inherited(sub)
|
11
|
+
logger.warn('The ActionMailer::ARMailer class has been deprecated. Will be removed in version 2.1. Just use ActionMailer::Base.')
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
class ActionMailer::Base
|
17
|
+
|
18
|
+
@@email_class = Email
|
19
|
+
|
20
|
+
##
|
21
|
+
# Current email class for deliveries.
|
22
|
+
|
23
|
+
def self.email_class
|
24
|
+
@@email_class
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Sets the email class for deliveries.
|
29
|
+
|
30
|
+
def self.email_class=(klass)
|
31
|
+
@@email_class = klass
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Adds +mail+ to the Email table. Only the first From address for +mail+ is
|
36
|
+
# used.
|
37
|
+
|
38
|
+
def perform_delivery_activerecord(mail)
|
39
|
+
mail.destinations.each do |destination|
|
40
|
+
@@email_class.create :mail => mail.encoded, :to => destination,
|
41
|
+
:from => mail.from.first
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|