Tuesday, April 6, 2010

Perl example: check mailserver

#!/usr/bin/perl
use Net::Telnet ();
$hostname = "enter a hostname or ip-address here";
$t = new Net::Telnet;
$t->open(Host => $hostname, Port => 110);
$line = $t->getline;
die $line unless $line =~ /^\+OK/;
print $line;
exit;


OUTPUT (example)
+OK Dovecot DA ready.