diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index 224939d..eac8f9b 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -35,8 +35,13 @@ module SMTPError attr_reader :response def initialize(response, message: nil) - @response = response - @message = message + if response.is_a?(::Net::SMTP::Response) + @response = response + @message = message + else + @response = nil + @message = message || response + end end def message @@ -643,7 +648,7 @@ def do_start(helo_domain, user, secret, authtype) do_helo helo_domain if ! tls? and (starttls_always? or (capable_starttls? and starttls_auto?)) unless capable_starttls? - raise SMTPUnsupportedCommand.new(nil, message: "STARTTLS is not supported on this server") + raise SMTPUnsupportedCommand, "STARTTLS is not supported on this server" end starttls @socket = new_internet_message_io(tlsconnect(s, @ssl_context_starttls))