Skip to content

Commit

Permalink
Fixed issue sending emails to unaffected recipients on 53x error
Browse files Browse the repository at this point in the history
When multiple recipients were specified and one recipient encountered
a 53x error, despite an exception being raised, emails were being sent
to the recipients that didn't encounter errors. This patch has been
applied to handle 53x errors the same way as other errors.
  • Loading branch information
tmtm committed Aug 12, 2023
1 parent 90f897a commit f4270f6
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions lib/net/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -906,23 +906,10 @@ def mailfrom(from_addr, require_smtputf8 = false)

def rcptto_list(to_addrs)
raise ArgumentError, 'mail destination not given' if to_addrs.empty?
ok_users = []
unknown_users = []
to_addrs.flatten.each do |addr|
begin
rcptto addr
rescue SMTPAuthenticationError
unknown_users << addr.to_s.dump
else
ok_users << addr
end
end
raise ArgumentError, 'mail destination not given' if ok_users.empty?
ret = yield
unless unknown_users.empty?
raise SMTPAuthenticationError, "failed to deliver for #{unknown_users.join(', ')}"
rcptto addr
end
ret
yield
end

# +to_addr+ is +String+ or +Net::SMTP::Address+
Expand Down

0 comments on commit f4270f6

Please sign in to comment.