Skip to content

Commit f60ccc6

Browse files
jethrogbjeremy
authored andcommitted
Fix Mail::Exim, forgotten in 4875bc2
The parameters of Mail::Sendmail.call changed in 4875bc2 but Mail::Exim was not changed accordingly. Backport to 2-5-stable References #689
1 parent 527067d commit f60ccc6

File tree

4 files changed

+35
-51
lines changed

4 files changed

+35
-51
lines changed

CHANGELOG.rdoc

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Security:
55

66
Bugs:
77
* #633 – Cope with message parts that have an empty Content-Type (ThomasKoppensteiner, zeepeeare)
8+
* #689 - Fix Exim delivery method broken by #477 in 2.5.4. (jethrogb)
89

910
== Version 2.5.4 - Tue May 14 14:45:00 +1100 2013 Mikel Lindsaar <[email protected]>
1011

lib/mail/network/delivery_methods/exim.rb

+6-10
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,13 @@ module Mail
3636
#
3737
# mail.deliver!
3838
class Exim < Sendmail
39-
def initialize(values)
40-
self.settings = { :location => '/usr/sbin/exim',
41-
:arguments => '-i -t' }.merge(values)
42-
end
39+
DEFAULTS = {
40+
:location => '/usr/sbin/exim',
41+
:arguments => '-i -t'
42+
}
4343

44-
def self.call(path, arguments, destinations, mail)
45-
popen "#{path} #{arguments}" do |io|
46-
io.puts mail.encoded.to_lf
47-
io.flush
48-
end
44+
def self.call(path, arguments, destinations, encoded_message)
45+
super path, arguments, nil, encoded_message
4946
end
50-
5147
end
5248
end

lib/mail/network/delivery_methods/sendmail.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ module Mail
3737
#
3838
# mail.deliver!
3939
class Sendmail
40+
DEFAULTS = {
41+
:location => '/usr/sbin/sendmail',
42+
:arguments => '-i'
43+
}
44+
4045
attr_accessor :settings
4146

4247
def initialize(values)
43-
self.settings = { :location => '/usr/sbin/sendmail',
44-
:arguments => '-i' }.merge(values)
48+
self.settings = self.class::DEFAULTS.merge(values)
4549
end
4650

4751
def deliver!(mail)

spec/mail/network/delivery_methods/exim_spec.rb

+22-39
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
2727
subject 'invalid RFC2822'
2828
end
29-
30-
Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
31-
'-i -t -f "[email protected]" --',
32-
33-
mail.encoded)
29+
30+
Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "[email protected]" --', nil, mail.encoded)
31+
3432
mail.deliver!
3533
end
3634

@@ -50,14 +48,10 @@
5048
message_id "<[email protected]>"
5149
body "body"
5250
end
53-
54-
Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
55-
'-i -t -f "[email protected]" --',
56-
57-
mail.encoded)
58-
59-
mail.deliver
6051

52+
Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "[email protected]" --', nil, mail.encoded)
53+
54+
mail.deliver
6155
end
6256

6357
it "should use the sender address is no return path is specified" do
@@ -74,14 +68,9 @@
7468
body "body"
7569
end
7670

77-
Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
78-
'-i -t -f "[email protected]" --',
79-
80-
mail.encoded)
81-
8271
mail.deliver
8372
end
84-
73+
8574
it "should use the from address is no return path or sender are specified" do
8675
Mail.defaults do
8776
delivery_method :exim
@@ -95,10 +84,8 @@
9584
body "body"
9685
end
9786

98-
Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
99-
'-i -t -f "[email protected]" --',
100-
101-
mail.encoded)
87+
Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "[email protected]" --', nil, mail.encoded)
88+
10289
mail.deliver
10390
end
10491

@@ -115,10 +102,8 @@
115102
body 'body'
116103
end
117104

118-
Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
119-
'-i -t -f "\"from+suffix test\"@test.lindsaar.net" --',
120-
121-
mail.encoded)
105+
Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "\"from+suffix test\"@test.lindsaar.net" --', nil, mail.encoded)
106+
122107
mail.deliver
123108
end
124109

@@ -132,10 +117,8 @@
132117
133118
end
134119

135-
Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
136-
'-i -t -f "[email protected]" --',
137-
138-
mail.encoded)
120+
Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "[email protected]" --', nil, mail.encoded)
121+
139122
mail.deliver
140123
end
141124
end
@@ -151,10 +134,8 @@
151134
subject 'invalid RFC2822'
152135
end
153136

154-
Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
155-
' -f "[email protected]" --',
156-
157-
mail.encoded)
137+
Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', ' -f "[email protected]" --', nil, mail.encoded)
138+
158139
mail.deliver!
159140
end
160141

@@ -168,11 +149,13 @@
168149
169150
subject 'invalid RFC2822'
170151
end
171-
172-
Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
173-
" -f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\" --",
174-
175-
mail.encoded)
152+
153+
Mail::Sendmail.should_receive(:call).with(
154+
'/usr/sbin/exim',
155+
" -f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\" --",
156+
nil,
157+
mail.encoded)
158+
176159
mail.deliver!
177160
end
178161

0 commit comments

Comments
 (0)