diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index 19baff6..ce4b23e 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -704,7 +704,9 @@ def tcp_socket(address, port) def do_start(helo_domain, user, secret, authtype, **auth) raise IOError, 'SMTP session already started' if @started - check_auth_args(authtype, user, secret, **auth) + if user || secret || authtype || auth.any? + check_auth_args(authtype, user, secret, **auth) + end s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do tcp_socket(@address, @port) end @@ -946,8 +948,8 @@ def auth(authtype = DEFAULT_AUTH_TYPE, *args, **kwargs, &block) private - def check_auth_args(type_arg = nil, *args, type: nil, **kwargs) - return unless type_arg || type || args.any? || kwargs.any? + def check_auth_args(type_arg = nil, *args, + type: nil, user: nil, **kwargs) type ||= type_arg || DEFAULT_AUTH_TYPE kwargs[:username] ||= user if user if (klass = Authenticator.auth_class(type))