Skip to content

Commit

Permalink
The mailfrom method's arguments restored.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtm committed Aug 14, 2023
1 parent cc51054 commit 40ed06d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/net/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ def any_require_smtputf8(addresses)
def send_message(msgstr, from_addr, *to_addrs)
to_addrs.flatten!
raise IOError, 'closed session' unless @socket
mailfrom from_addr, any_require_smtputf8(to_addrs)
from_addr = Address.new(from_addr, 'SMTPUTF8') if any_require_smtputf8(to_addrs) && capable?('SMTPUTF8')
mailfrom from_addr
rcptto_list(to_addrs) {data msgstr}
end

Expand Down Expand Up @@ -823,7 +824,8 @@ def send_message(msgstr, from_addr, *to_addrs)
def open_message_stream(from_addr, *to_addrs, &block) # :yield: stream
to_addrs.flatten!
raise IOError, 'closed session' unless @socket
mailfrom from_addr, any_require_smtputf8(to_addrs)
from_addr = Address.new(from_addr, 'SMTPUTF8') if any_require_smtputf8(to_addrs) && capable?('SMTPUTF8')
mailfrom from_addr
rcptto_list(to_addrs) {data(&block)}
end

Expand Down Expand Up @@ -890,8 +892,8 @@ def ehlo(domain)
end

# +from_addr+ is +String+ or +Net::SMTP::Address+
def mailfrom(from_addr, require_smtputf8 = false)
addr = if require_smtputf8 || requires_smtputf8(from_addr)
def mailfrom(from_addr)
addr = if requires_smtputf8(from_addr)
raise SMTPUTF8RequiredError, "Message requires SMTPUTF8 but server does not support that" unless capable? "SMTPUTF8"
Address.new(from_addr, "SMTPUTF8")
else
Expand Down Expand Up @@ -1128,7 +1130,7 @@ def initialize(address, *args, **kw_args)
@address = address
@parameters = []
end
@parameters = (parameters + args + [kw_args]).map{|param| Array(param)}.flatten(1).map{|param| Array(param).compact.join('=')}
@parameters = (parameters + args + [kw_args]).map{|param| Array(param)}.flatten(1).map{|param| Array(param).compact.join('=')}.uniq
end

def to_s
Expand Down

0 comments on commit 40ed06d

Please sign in to comment.