From db01cc0015581b5bf09733b567c3abfb6e006744 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 18 Feb 2013 10:46:11 +0000 Subject: Deleted trailing whitespace. --- lib/custodian/protocoltest/smtprelay.rb | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'lib/custodian/protocoltest') diff --git a/lib/custodian/protocoltest/smtprelay.rb b/lib/custodian/protocoltest/smtprelay.rb index 2280f10..d3a223a 100644 --- a/lib/custodian/protocoltest/smtprelay.rb +++ b/lib/custodian/protocoltest/smtprelay.rb @@ -56,6 +56,21 @@ module Custodian @line end + + # + # Read the hostname for usage in the SMTP-transaction. + # + def get_hostname + hostname = "localhost.localdomain" + + if ( File.exists?( "/etc/hostname" ) ) + end + + hostname + end + + + # # run the test for open relays of SMTP protocol - return true on success. # false on fail. @@ -67,26 +82,26 @@ module Custodian begin - Net::SMTP.start(@host,@port) do |smtp| + Net::SMTP.start(@host,@port, get_hostname() ) do |smtp| sent = smtp.send_message message, "noreply@bytemark.co.uk", "noreply@bytemark.co.uk" @status = sent.status.to_s if @status === "250" @error = "NOT OK: message sent on #{@host} with status #{@status}" - else + else @error = "OK: message not sent on #{@host} with status #{@status}" end - + # # give the parser an appropriate response depending on the smtp code # and whether or not we're inverting the test. (eg, 'must not') # - + return @inverted if @status == "250" and @inverted return !@inverted if @status == "250" and !@inverted return @inverted if @status != "250" and !@inverted return !@inverted if @status != "250" and @inverted - + end # Net SMTP rescue Exception => ex @@ -95,7 +110,7 @@ module Custodian # @error = "OK: Timed out or connection refused on #{@host} with status #{@status}" return !@inverted if @inverted - return @inverted if !@inverted + return @inverted if !@inverted end end -- cgit v1.2.1