Class: ServerUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/maildis/server_utils.rb

Class Method Summary collapse

Class Method Details

.server_reachable?(host, port = 25) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
# File 'lib/maildis/server_utils.rb', line 7

def server_reachable?(host, port=25)
  begin
    TCPSocket.new(host, port).close
    true
  rescue Errno::ECONNREFUSED
    false
  rescue => e
    $stderr.puts "Error during mail server status check: " + e.message
  end
end