From 8b3d1c4f7048a73835e96662cf094d4db67f4e23 Mon Sep 17 00:00:00 2001 From: nicholas evans Date: Mon, 9 Oct 2023 09:05:09 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/net/smtp.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index 6a990e7..978a4bb 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -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) @@ -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 @@ -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) @@ -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 @@ -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]