adzap-ar_mailer 2.1.5 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -5
- data/README.rdoc +7 -14
- data/Rakefile +25 -6
- data/lib/action_mailer/ar_mailer.rb +2 -1
- data/lib/action_mailer/ar_sendmail.rb +9 -11
- data/share/linux/ar_sendmail +3 -3
- data/test/test_armailer.rb +11 -0
- data/test/test_arsendmail.rb +15 -40
- metadata +3 -3
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
= 2.1.6
|
2
|
+
|
3
|
+
* Miscellaneous Updates
|
4
|
+
* Use return-path as from address if set, as per default ActionMailer::Base SMTP delivery (Dustin Tinney)
|
5
|
+
* Always wait full delay between deliveries (cyu)
|
6
|
+
|
7
|
+
* Bugs fixed
|
8
|
+
* Non-zero return code returned in init.d script (hennk)
|
9
|
+
* Use updated Timeout error class (hennk)
|
10
|
+
|
1
11
|
= 2.1.5
|
2
12
|
|
3
13
|
* Bugs fixed
|
@@ -21,7 +31,7 @@
|
|
21
31
|
* Require ar_mailer in ar_sendmail since the change to remove TableName and use email_class
|
22
32
|
|
23
33
|
= 2.1.1
|
24
|
-
|
34
|
+
|
25
35
|
* Force gem rebuild
|
26
36
|
|
27
37
|
= 2.1.0
|
@@ -55,7 +65,7 @@
|
|
55
65
|
= 1.4.3
|
56
66
|
|
57
67
|
* Bugs fixed
|
58
|
-
* Replaced mistaken call to log when removing pid file artifact for
|
68
|
+
* Replaced mistaken call to log when removing pid file artifact for
|
59
69
|
non-running daemon
|
60
70
|
|
61
71
|
= 1.4.2
|
@@ -65,11 +75,11 @@
|
|
65
75
|
config file. See files share/linux/ar_sendmail and ar_sendmail.conf
|
66
76
|
* Bugs fixed
|
67
77
|
* Proper handling for relative and absolute paths for the pid file
|
68
|
-
* Removed hoe dependency since we need the explicit gemspec file for github and
|
78
|
+
* Removed hoe dependency since we need the explicit gemspec file for github and
|
69
79
|
not deploying to RubyForge its not as useful.
|
70
|
-
* Moved old BSD rc.d script to share/bsd folder
|
80
|
+
* Moved old BSD rc.d script to share/bsd folder
|
71
81
|
* Updated README with github gem install, docs and init script info
|
72
|
-
|
82
|
+
|
73
83
|
= 1.4.1
|
74
84
|
|
75
85
|
* Bugs fixed
|
data/README.rdoc
CHANGED
@@ -30,19 +30,12 @@ Before installing you will need to make sure the original gem is uninstalled as
|
|
30
30
|
|
31
31
|
$ sudo gem uninstall ar_mailer
|
32
32
|
|
33
|
-
Install the gem from Gemcutter gems server:
|
34
|
-
|
35
|
-
First, if you haven't already:
|
36
|
-
|
37
|
-
$ sudo gem install gemcutter
|
38
|
-
$ sudo gem tumble
|
39
|
-
|
40
33
|
Then
|
41
34
|
|
42
35
|
$ sudo gem install adzap-ar_mailer
|
43
36
|
|
44
37
|
For Rails >= 2.1, in your environment.rb:
|
45
|
-
|
38
|
+
|
46
39
|
config.gem "adzap-ar_mailer", :lib => 'action_mailer/ar_mailer', :source => 'http://gemcutter.com'
|
47
40
|
|
48
41
|
For Rails 2.0, in an initializer file:
|
@@ -89,9 +82,9 @@ Or if you need to, you can set each mailer class delivery method individually:
|
|
89
82
|
end
|
90
83
|
|
91
84
|
This can be useful when using plugins like ExceptionNotification. Where it
|
92
|
-
might be foolish to tie the sending of the email alert to the database when the
|
85
|
+
might be foolish to tie the sending of the email alert to the database when the
|
93
86
|
database might be causing the exception being raised. In this instance you could
|
94
|
-
override ExceptionNofitier delivery method to be smtp or set the other
|
87
|
+
override ExceptionNofitier delivery method to be smtp or set the other
|
95
88
|
mailer classes to use ARMailer explicitly.
|
96
89
|
|
97
90
|
Then to run it:
|
@@ -117,7 +110,7 @@ SMTP server supports it. If you do not want it to automatically enabled then
|
|
117
110
|
set the :tls option to false in your smtp_settings.
|
118
111
|
|
119
112
|
If you are on Ruby <= 1.8.6, then the TLS patch included in this plugin will
|
120
|
-
be loaded, so you don't need another TLS plugin to add the capability. This
|
113
|
+
be loaded, so you don't need another TLS plugin to add the capability. This
|
121
114
|
patch allows you to explicit set if the server supports TLS by setting the
|
122
115
|
:tls option to true in your smtp_settings.
|
123
116
|
|
@@ -130,10 +123,10 @@ around. ar_mailer supplies it own.
|
|
130
123
|
|
131
124
|
== Run as a service (init.d/rc.d scripts)
|
132
125
|
|
133
|
-
For Linux both script and demo config files are in share/linux.
|
134
|
-
See ar_sendmail.conf for setting up your config. Copy the ar_sendmail file
|
126
|
+
For Linux both script and demo config files are in share/linux.
|
127
|
+
See ar_sendmail.conf for setting up your config. Copy the ar_sendmail file
|
135
128
|
to /etc/init.d/ and make it executable. Then for Debian based distros run
|
136
|
-
'sudo update-rc.d ar_sendmail defaults' and it should work. Make sure you have
|
129
|
+
'sudo update-rc.d ar_sendmail defaults' and it should work. Make sure you have
|
137
130
|
the config file /etc/ar_sendmail.conf in place before starting.
|
138
131
|
|
139
132
|
For FreeBSD or NetBSD script is share/bsd/ar_sendmail. This is old and does not
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'rake/rdoctask'
|
|
6
6
|
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/lib'))
|
7
7
|
|
8
8
|
require './lib/action_mailer/ar_sendmail'
|
9
|
-
|
9
|
+
|
10
10
|
ar_mailer_gemspec = Gem::Specification.new do |s|
|
11
11
|
s.name = %q{adzap-ar_mailer}
|
12
12
|
s.version = ActionMailer::ARSendmail::VERSION
|
@@ -17,7 +17,26 @@ ar_mailer_gemspec = Gem::Specification.new do |s|
|
|
17
17
|
s.email = %q{adam.meehan@gmail.com}
|
18
18
|
s.executables = ["ar_sendmail"]
|
19
19
|
s.extra_rdoc_files = ["History.txt", "LICENSE.txt", "README.rdoc"]
|
20
|
-
s.files = [
|
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/action_mailer/ar_mailer.rb",
|
30
|
+
"lib/action_mailer/ar_sendmail.rb",
|
31
|
+
"lib/smtp_tls.rb",
|
32
|
+
"share/bsd/ar_sendmail",
|
33
|
+
"share/linux/ar_sendmail",
|
34
|
+
"share/linux/ar_sendmail.conf",
|
35
|
+
"test/resources/action_mailer.rb",
|
36
|
+
"test/test_armailer.rb",
|
37
|
+
"test/test_arsendmail.rb",
|
38
|
+
"test/test_helper.rb"
|
39
|
+
]
|
21
40
|
s.has_rdoc = true
|
22
41
|
s.homepage = %q{http://github.com/adzap/ar_mailer}
|
23
42
|
s.rdoc_options = ["--main", "README.rdoc"]
|
@@ -25,19 +44,19 @@ ar_mailer_gemspec = Gem::Specification.new do |s|
|
|
25
44
|
s.rubyforge_project = %q{seattlerb}
|
26
45
|
s.summary = %q{A two-phase delivery agent for ActionMailer}
|
27
46
|
s.test_files = ["test/test_armailer.rb", "test/test_arsendmail.rb"]
|
28
|
-
end
|
47
|
+
end
|
29
48
|
|
30
49
|
Rake::GemPackageTask.new(ar_mailer_gemspec) do |pkg|
|
31
50
|
pkg.gem_spec = ar_mailer_gemspec
|
32
51
|
end
|
33
|
-
|
52
|
+
|
34
53
|
desc "Update ar_mailer.gemspec"
|
35
54
|
task :make_spec do
|
36
|
-
File.open("ar_mailer.gemspec", "w") do |f|
|
55
|
+
File.open("adzap-ar_mailer.gemspec", "w") do |f|
|
37
56
|
f.puts(ar_mailer_gemspec.to_ruby)
|
38
57
|
end
|
39
58
|
end
|
40
|
-
|
59
|
+
|
41
60
|
desc "Build packages and install"
|
42
61
|
task :install => :package do
|
43
62
|
sh %{sudo gem install --local --test pkg/ar_mailer-#{ActionMailer::ARSendmail::VERSION}}
|
@@ -23,8 +23,9 @@ class ActionMailer::Base
|
|
23
23
|
# used.
|
24
24
|
|
25
25
|
def perform_delivery_activerecord(mail)
|
26
|
+
sender = (mail['return-path'] && mail['return-path'].spec) || mail['from']
|
26
27
|
mail.destinations.each do |destination|
|
27
|
-
self.class.email_class.create :mail => mail.encoded, :to => destination, :from =>
|
28
|
+
self.class.email_class.create :mail => mail.encoded, :to => destination, :from => sender
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
@@ -42,7 +42,7 @@ class ActionMailer::ARSendmail
|
|
42
42
|
##
|
43
43
|
# The version of ActionMailer::ARSendmail you are running.
|
44
44
|
|
45
|
-
VERSION = '2.1.
|
45
|
+
VERSION = '2.1.6'
|
46
46
|
|
47
47
|
##
|
48
48
|
# Maximum number of times authentication will be consecutively retried
|
@@ -68,7 +68,7 @@ class ActionMailer::ARSendmail
|
|
68
68
|
# Be verbose
|
69
69
|
|
70
70
|
attr_accessor :verbose
|
71
|
-
|
71
|
+
|
72
72
|
|
73
73
|
##
|
74
74
|
# True if only one delivery attempt will be made per call to run
|
@@ -282,7 +282,7 @@ class ActionMailer::ARSendmail
|
|
282
282
|
File.open(@@pid_file, 'r') {|f| pid = f.read.chomp }
|
283
283
|
if system("ps -p #{pid} | grep #{pid}") # returns true if process is running, o.w. false
|
284
284
|
$stderr.puts "Warning: The pid file #{@@pid_file} exists and ar_sendmail is running. Shutting down."
|
285
|
-
exit
|
285
|
+
exit -1
|
286
286
|
else
|
287
287
|
# not running, so remove existing pid file and continue
|
288
288
|
self.remove_pid_file
|
@@ -302,7 +302,7 @@ class ActionMailer::ARSendmail
|
|
302
302
|
rescue Exception => e
|
303
303
|
$stderr.puts "Unhandled exception #{e.message}(#{e.class}):"
|
304
304
|
$stderr.puts "\t#{e.backtrace.join "\n\t"}"
|
305
|
-
exit
|
305
|
+
exit -2
|
306
306
|
end
|
307
307
|
|
308
308
|
##
|
@@ -363,7 +363,7 @@ class ActionMailer::ARSendmail
|
|
363
363
|
smtp_settings[:password],
|
364
364
|
smtp_settings[:authentication]
|
365
365
|
]
|
366
|
-
|
366
|
+
|
367
367
|
smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
|
368
368
|
if smtp.respond_to?(:enable_starttls_auto)
|
369
369
|
smtp.enable_starttls_auto unless smtp_settings[:tls] == false
|
@@ -386,10 +386,9 @@ class ActionMailer::ARSendmail
|
|
386
386
|
email.destroy
|
387
387
|
session.reset
|
388
388
|
rescue Net::SMTPServerBusy => e
|
389
|
-
log "server too busy,
|
390
|
-
sleep delay
|
389
|
+
log "server too busy, stopping delivery cycle"
|
391
390
|
return
|
392
|
-
rescue Net::SMTPUnknownError, Net::SMTPSyntaxError, TimeoutError => e
|
391
|
+
rescue Net::SMTPUnknownError, Net::SMTPSyntaxError, TimeoutError, Timeout::Error => e
|
393
392
|
email.last_send_attempt = Time.now.to_i
|
394
393
|
email.save rescue nil
|
395
394
|
log "error sending email %d: %p(%s):\n\t%s" %
|
@@ -417,7 +416,7 @@ class ActionMailer::ARSendmail
|
|
417
416
|
def do_exit
|
418
417
|
log "caught signal, shutting down"
|
419
418
|
self.class.remove_pid_file
|
420
|
-
exit
|
419
|
+
exit 130
|
421
420
|
end
|
422
421
|
|
423
422
|
##
|
@@ -457,7 +456,6 @@ class ActionMailer::ARSendmail
|
|
457
456
|
install_signal_handlers
|
458
457
|
|
459
458
|
loop do
|
460
|
-
now = Time.now
|
461
459
|
begin
|
462
460
|
cleanup
|
463
461
|
emails = find_emails
|
@@ -465,7 +463,7 @@ class ActionMailer::ARSendmail
|
|
465
463
|
rescue ActiveRecord::Transactions::TransactionError
|
466
464
|
end
|
467
465
|
break if @once
|
468
|
-
sleep @delay
|
466
|
+
sleep @delay
|
469
467
|
end
|
470
468
|
end
|
471
469
|
|
data/share/linux/ar_sendmail
CHANGED
@@ -14,11 +14,11 @@ begin
|
|
14
14
|
config = YAML::load(IO.read(config_file)) || {}
|
15
15
|
if config.empty? || (config.has_key?('defaults') && config.size == 1)
|
16
16
|
puts "No mailers defined. Exiting."
|
17
|
-
exit
|
17
|
+
exit -2
|
18
18
|
end
|
19
19
|
rescue Errno::ENOENT
|
20
20
|
puts "Config file not found at '#{config_file}'!"
|
21
|
-
exit
|
21
|
+
exit -3
|
22
22
|
end
|
23
23
|
|
24
24
|
default_options = {'pidfile' => './log/ar_sendmail.pid'}.merge(config.delete('defaults') || {})
|
@@ -57,7 +57,7 @@ end
|
|
57
57
|
|
58
58
|
def command_error(msg)
|
59
59
|
puts msg
|
60
|
-
exit
|
60
|
+
exit -1
|
61
61
|
end
|
62
62
|
|
63
63
|
if ['start', 'stop', 'restart'].include?(command)
|
data/test/test_armailer.rb
CHANGED
@@ -7,6 +7,7 @@ class Mailer < ActionMailer::Base
|
|
7
7
|
@mail = Object.new
|
8
8
|
def @mail.encoded() 'email' end
|
9
9
|
def @mail.from() ['nobody@example.com'] end
|
10
|
+
def @mail.[](key) {'return-path' => $return_path, 'from' => 'nobody@example.com'}[key] end
|
10
11
|
def @mail.destinations() %w[user1@example.com user2@example.com] end
|
11
12
|
end
|
12
13
|
|
@@ -15,6 +16,7 @@ end
|
|
15
16
|
class TestARMailer < Test::Unit::TestCase
|
16
17
|
|
17
18
|
def setup
|
19
|
+
$return_path = nil
|
18
20
|
Mailer.email_class = Email
|
19
21
|
|
20
22
|
Email.records.clear
|
@@ -28,6 +30,15 @@ class TestARMailer < Test::Unit::TestCase
|
|
28
30
|
|
29
31
|
assert_equal 2, Newsletter.records.length
|
30
32
|
end
|
33
|
+
|
34
|
+
def test_perform_delivery_activerecord_when_return_path_is_present
|
35
|
+
$return_path = stub(:spec => 'return-path@example.com')
|
36
|
+
Mailer.deliver_mail
|
37
|
+
|
38
|
+
assert_equal 2, Email.records.length
|
39
|
+
record = Email.records.first
|
40
|
+
assert_equal 'return-path@example.com', record.from
|
41
|
+
end
|
31
42
|
|
32
43
|
def test_perform_delivery_activerecord
|
33
44
|
Mailer.deliver_mail
|
data/test/test_arsendmail.rb
CHANGED
@@ -98,19 +98,19 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
|
|
98
98
|
|
99
99
|
def test_class_parse_args_chdir
|
100
100
|
argv = %w[-c /tmp]
|
101
|
-
|
101
|
+
|
102
102
|
options = ActionMailer::ARSendmail.process_args argv
|
103
103
|
|
104
104
|
assert_equal '/tmp', options[:Chdir]
|
105
105
|
|
106
106
|
argv = %w[--chdir /tmp]
|
107
|
-
|
107
|
+
|
108
108
|
options = ActionMailer::ARSendmail.process_args argv
|
109
109
|
|
110
110
|
assert_equal '/tmp', options[:Chdir]
|
111
111
|
|
112
112
|
argv = %w[-c /nonexistent]
|
113
|
-
|
113
|
+
|
114
114
|
out, err = capture_io do
|
115
115
|
assert_raises SystemExit do
|
116
116
|
ActionMailer::ARSendmail.process_args argv
|
@@ -120,35 +120,35 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
|
|
120
120
|
|
121
121
|
def test_class_parse_args_daemon
|
122
122
|
argv = %w[-d]
|
123
|
-
|
123
|
+
|
124
124
|
options = ActionMailer::ARSendmail.process_args argv
|
125
125
|
|
126
126
|
assert_equal true, options[:Daemon]
|
127
127
|
|
128
128
|
argv = %w[--daemon]
|
129
|
-
|
129
|
+
|
130
130
|
options = ActionMailer::ARSendmail.process_args argv
|
131
131
|
|
132
132
|
assert_equal true, options[:Daemon]
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
def test_class_parse_args_pidfile
|
136
136
|
argv = %w[-p ./log/ar_sendmail.pid]
|
137
|
-
|
137
|
+
|
138
138
|
options = ActionMailer::ARSendmail.process_args argv
|
139
139
|
|
140
140
|
assert_equal './log/ar_sendmail.pid', options[:Pidfile]
|
141
141
|
|
142
142
|
argv = %w[--pidfile ./log/ar_sendmail.pid]
|
143
|
-
|
143
|
+
|
144
144
|
options = ActionMailer::ARSendmail.process_args argv
|
145
145
|
|
146
146
|
assert_equal './log/ar_sendmail.pid', options[:Pidfile]
|
147
147
|
end
|
148
|
-
|
148
|
+
|
149
149
|
def test_class_parse_args_delay
|
150
150
|
argv = %w[--delay 75]
|
151
|
-
|
151
|
+
|
152
152
|
options = ActionMailer::ARSendmail.process_args argv
|
153
153
|
|
154
154
|
assert_equal 75, options[:Delay]
|
@@ -158,7 +158,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
|
|
158
158
|
assert_equal nil, ENV['RAILS_ENV']
|
159
159
|
|
160
160
|
argv = %w[-e production]
|
161
|
-
|
161
|
+
|
162
162
|
options = ActionMailer::ARSendmail.process_args argv
|
163
163
|
|
164
164
|
assert_equal 'production', options[:RailsEnv]
|
@@ -166,7 +166,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
|
|
166
166
|
assert_equal 'production', ENV['RAILS_ENV']
|
167
167
|
|
168
168
|
argv = %w[--environment production]
|
169
|
-
|
169
|
+
|
170
170
|
options = ActionMailer::ARSendmail.process_args argv
|
171
171
|
|
172
172
|
assert_equal 'production', options[:RailsEnv]
|
@@ -177,7 +177,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
|
|
177
177
|
refute_includes options, :MailQ
|
178
178
|
|
179
179
|
argv = %w[--mailq]
|
180
|
-
|
180
|
+
|
181
181
|
options = ActionMailer::ARSendmail.process_args argv
|
182
182
|
|
183
183
|
assert_equal true, options[:MailQ]
|
@@ -209,13 +209,13 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
|
|
209
209
|
|
210
210
|
def test_class_parse_args_once
|
211
211
|
argv = %w[-o]
|
212
|
-
|
212
|
+
|
213
213
|
options = ActionMailer::ARSendmail.process_args argv
|
214
214
|
|
215
215
|
assert_equal true, options[:Once]
|
216
216
|
|
217
217
|
argv = %w[--once]
|
218
|
-
|
218
|
+
|
219
219
|
options = ActionMailer::ARSendmail.process_args argv
|
220
220
|
|
221
221
|
assert_equal true, options[:Once]
|
@@ -420,31 +420,6 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
|
|
420
420
|
assert_equal '', err
|
421
421
|
end
|
422
422
|
|
423
|
-
def test_deliver_server_busy
|
424
|
-
Net::SMTP.on_send_message do
|
425
|
-
e = Net::SMTPServerBusy.new 'try again'
|
426
|
-
e.set_backtrace %w[one two three]
|
427
|
-
raise e
|
428
|
-
end
|
429
|
-
|
430
|
-
now = Time.now.to_i
|
431
|
-
|
432
|
-
email = Email.create :mail => 'body', :to => 'to', :from => 'from'
|
433
|
-
|
434
|
-
out, err = capture_io do
|
435
|
-
@sm.deliver [email]
|
436
|
-
end
|
437
|
-
|
438
|
-
assert_equal 0, Net::SMTP.deliveries.length
|
439
|
-
assert_equal 1, Email.records.length
|
440
|
-
assert_operator now, :>=, Email.records.first.last_send_attempt
|
441
|
-
assert_equal 0, Net::SMTP.reset_called, 'Reset connection on SyntaxError'
|
442
|
-
assert_equal [60], @sm.slept
|
443
|
-
|
444
|
-
assert_equal '', out
|
445
|
-
assert_equal "server too busy, sleeping 60 seconds\n", err
|
446
|
-
end
|
447
|
-
|
448
423
|
def test_deliver_syntax_error
|
449
424
|
Net::SMTP.on_send_message do
|
450
425
|
Net::SMTP.on_send_message # clear
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adzap-ar_mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Hodel
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2010-01-16 00:00:00 +11:00
|
14
14
|
default_executable: ar_sendmail
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
requirements: []
|
69
69
|
|
70
70
|
rubyforge_project: seattlerb
|
71
|
-
rubygems_version: 1.3.
|
71
|
+
rubygems_version: 1.3.5
|
72
72
|
signing_key:
|
73
73
|
specification_version: 3
|
74
74
|
summary: A two-phase delivery agent for ActionMailer
|