Skip to content

Commit 0398459

Browse files
committed
Change sendmail default options to match Mail 2.8.x arguments format.
The Mail gem changed format of the delivery method arguments for sendmail from a string to an array of strings in this commit mikel/mail@7e1196b As the settings are now a sendmail delivery method produces the following error: ``` .../mail-2.8.0/lib/mail/network/delivery_methods/sendmail.rb:53:in `initialize': :arguments expected to be an Array of individual string args (ArgumentError) ``` This also updates the mail dependency since the new default won't work with the older versions.
1 parent 7069d15 commit 0398459

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

Gemfile.lock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,11 @@ GEM
315315
loofah (2.13.0)
316316
crass (~> 1.0.2)
317317
nokogiri (>= 1.5.9)
318-
mail (2.7.1)
318+
mail (2.8.0)
319319
mini_mime (>= 0.1.1)
320+
net-imap
321+
net-pop
322+
net-smtp
320323
marcel (1.0.2)
321324
matrix (0.4.2)
322325
memoist (0.16.2)

actionmailer/lib/action_mailer/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ module ActionMailer
439439
#
440440
# * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
441441
# * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
442-
# * <tt>:arguments</tt> - The command line arguments. Defaults to <tt>-i</tt> with <tt>-f sender@address</tt>
442+
# * <tt>:arguments</tt> - The command line arguments. Defaults to <tt>%w[ -i ]</tt> with <tt>-f sender@address</tt>
443443
# added automatically before the message is sent.
444444
#
445445
# * <tt>file_settings</tt> - Allows you to override options for the <tt>:file</tt> delivery method.

actionmailer/lib/action_mailer/delivery_methods.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ module DeliveryMethods
3131

3232
add_delivery_method :sendmail, Mail::Sendmail,
3333
location: "/usr/sbin/sendmail",
34-
arguments: "-i"
34+
# See breaking change in the mail gem - https://github.com/mikel/mail/commit/7e1196bd29815a0901d7290c82a332c0959b163a
35+
arguments: Gem::Version.new(Mail::VERSION.version) >= Gem::Version.new("2.8.0") ? %w[-i] : "-i"
3536

3637
add_delivery_method :test, Mail::TestMailer
3738
end
@@ -46,7 +47,7 @@ module ClassMethods
4647
#
4748
# add_delivery_method :sendmail, Mail::Sendmail,
4849
# location: '/usr/sbin/sendmail',
49-
# arguments: '-i'
50+
# arguments: %w[ -i ]
5051
def add_delivery_method(symbol, klass, default_options = {})
5152
class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
5253
public_send(:"#{symbol}_settings=", default_options)

actionmailer/test/delivery_methods_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DefaultsDeliveryMethodsTest < ActiveSupport::TestCase
4141
test "default sendmail settings" do
4242
settings = {
4343
location: "/usr/sbin/sendmail",
44-
arguments: "-i"
44+
arguments: %w[ -i ]
4545
}
4646
assert_equal settings, ActionMailer::Base.sendmail_settings
4747
end

guides/source/action_mailer_basics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ config.action_mailer.delivery_method = :sendmail
839839
# Defaults to:
840840
# config.action_mailer.sendmail_settings = {
841841
# location: '/usr/sbin/sendmail',
842-
# arguments: '-i'
842+
# arguments: %w[ -i ]
843843
# }
844844
config.action_mailer.perform_deliveries = true
845845
config.action_mailer.raise_delivery_errors = true

guides/source/configuring.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,7 @@ The default value depends on the `config.load_defaults` target version:
19101910
Allows detailed configuration for the `sendmail` delivery method. It accepts a hash of options, which can include any of these options:
19111911

19121912
* `:location` - The location of the sendmail executable. Defaults to `/usr/sbin/sendmail`.
1913-
* `:arguments` - The command line arguments. Defaults to `-i`.
1913+
* `:arguments` - The command line arguments. Defaults to `%w[ -i ]`.
19141914

19151915
#### `config.action_mailer.raise_delivery_errors`
19161916

0 commit comments

Comments
 (0)