Skip to content

Commit

Permalink
🚧 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nevans committed Oct 9, 2023
1 parent 8e8297b commit 8b3d1c4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/net/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,9 @@ def start(*args, helo: nil,
user ||= args[1]
secret ||= password || args[2]
authtype ||= args[3]
auth ||= [user, secret, authtype] if user || secret
if user || secret || authtype
auth ||= [user, secret, authtype || DEFAULT_AUTH_TYPE]
end
if defined?(OpenSSL::VERSION)
ssl_context_params = @ssl_context_params || {}
unless ssl_context_params.has_key?(:verify_mode)
Expand All @@ -647,13 +649,13 @@ def start(*args, helo: nil,
end
if block_given?
begin
do_start helo, user, secret, authtype, auth
do_start helo, auth
return yield(self)
ensure
do_finish
end
else
do_start helo, user, secret, authtype, auth
do_start helo, auth
return self
end
end
Expand All @@ -671,8 +673,7 @@ def tcp_socket(address, port)
TCPSocket.open address, port
end

def do_start(helo_domain, user, secret, authtype, auth = nil)
# pp({method: __method__, user:, secret:, authtype:, auth:}.compact)
def do_start(helo_domain, auth)
raise IOError, 'SMTP session already started' if @started
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
tcp_socket(@address, @port)
Expand All @@ -690,7 +691,7 @@ def do_start(helo_domain, user, secret, authtype, auth = nil)
# helo response may be different after STARTTLS
do_helo helo_domain
end
authenticate user, secret, (authtype || DEFAULT_AUTH_TYPE) if user
authenticate(*auth) if auth
@started = true
ensure
unless @started
Expand Down Expand Up @@ -893,7 +894,7 @@ def authenticate(*args, **kwargs)
when 2..3
unless kwargs.empty?
raise ArgumentError, "do not send keyword arguments when using " \
"positional user and secret arguments"
"positional 'user' and 'secret' arguments"
end
user = args[0]
secret = args[1]
Expand Down

0 comments on commit 8b3d1c4

Please sign in to comment.