#!/usr/bin/expect -f

# SMTP Expect module for sawdog

set env(TERM) vt100

set timeout 8
match_max 100000

for {set x 0} {$x<3} {incr x} {
   spawn telnet $argv 25
   expect "Connection refused" {
      exit 2
   } "Escape character is '^\]'.\r\r" {
      expect "220" { 
         send -- "quit\r"
      exit 0
      }
   } 
   sleep 5
}
exit 1
