Skip to content

Commit

Permalink
Fix Mail::Exim, forgotten in 4875bc2
Browse files Browse the repository at this point in the history
The parameters of Mail::Sendmail.call changed in 4875bc2 but
Mail::Exim was not changed accordingly.

Backport to 2-5-stable

References #689
  • Loading branch information
jethrogb authored and jeremy committed May 17, 2017
1 parent 527067d commit f60ccc6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 51 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Security:

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

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

Expand Down
16 changes: 6 additions & 10 deletions lib/mail/network/delivery_methods/exim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@ module Mail
#
# mail.deliver!
class Exim < Sendmail
def initialize(values)
self.settings = { :location => '/usr/sbin/exim',
:arguments => '-i -t' }.merge(values)
end
DEFAULTS = {
:location => '/usr/sbin/exim',
:arguments => '-i -t'
}

def self.call(path, arguments, destinations, mail)
popen "#{path} #{arguments}" do |io|
io.puts mail.encoded.to_lf
io.flush
end
def self.call(path, arguments, destinations, encoded_message)
super path, arguments, nil, encoded_message
end

end
end
8 changes: 6 additions & 2 deletions lib/mail/network/delivery_methods/sendmail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ module Mail
#
# mail.deliver!
class Sendmail
DEFAULTS = {
:location => '/usr/sbin/sendmail',
:arguments => '-i'
}

attr_accessor :settings

def initialize(values)
self.settings = { :location => '/usr/sbin/sendmail',
:arguments => '-i' }.merge(values)
self.settings = self.class::DEFAULTS.merge(values)
end

def deliver!(mail)
Expand Down
61 changes: 22 additions & 39 deletions spec/mail/network/delivery_methods/exim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
to '[email protected], [email protected]'
subject 'invalid RFC2822'
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "[email protected]" --',
'"[email protected]" "[email protected]"',
mail.encoded)

Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "[email protected]" --', nil, mail.encoded)

mail.deliver!
end

Expand All @@ -50,14 +48,10 @@
message_id "<[email protected]>"
body "body"
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "[email protected]" --',
'"[email protected]"',
mail.encoded)

mail.deliver

Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "[email protected]" --', nil, mail.encoded)

mail.deliver
end

it "should use the sender address is no return path is specified" do
Expand All @@ -74,14 +68,9 @@
body "body"
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "[email protected]" --',
'"[email protected]"',
mail.encoded)

mail.deliver
end

it "should use the from address is no return path or sender are specified" do
Mail.defaults do
delivery_method :exim
Expand All @@ -95,10 +84,8 @@
body "body"
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "[email protected]" --',
'"[email protected]"',
mail.encoded)
Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "[email protected]" --', nil, mail.encoded)

mail.deliver
end

Expand All @@ -115,10 +102,8 @@
body 'body'
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "\"from+suffix test\"@test.lindsaar.net" --',
'"[email protected]"',
mail.encoded)
Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "\"from+suffix test\"@test.lindsaar.net" --', nil, mail.encoded)

mail.deliver
end

Expand All @@ -132,10 +117,8 @@
from '[email protected]'
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "[email protected]" --',
'"[email protected]"',
mail.encoded)
Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "[email protected]" --', nil, mail.encoded)

mail.deliver
end
end
Expand All @@ -151,10 +134,8 @@
subject 'invalid RFC2822'
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
' -f "[email protected]" --',
'"[email protected]" "[email protected]"',
mail.encoded)
Mail::Sendmail.should_receive(:call).with('/usr/sbin/exim', ' -f "[email protected]" --', nil, mail.encoded)

mail.deliver!
end

Expand All @@ -168,11 +149,13 @@
to '[email protected]'
subject 'invalid RFC2822'
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
" -f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\" --",
'"[email protected]"',
mail.encoded)

Mail::Sendmail.should_receive(:call).with(
'/usr/sbin/exim',
" -f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\" --",
nil,
mail.encoded)

mail.deliver!
end

Expand Down

0 comments on commit f60ccc6

Please sign in to comment.