#!/usr/bin/expect -f

# POP3 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 pop3
   expect "Connection refused" {
      exit 2
   } "Escape character is '^\]'.\r\r" {
      expect "+OK" { 
         send -- "quit\r"
         exit 0
      }
   } 
   sleep 5
}
exit 1
