use strict; use warnings; use Net::Telnet; my $tel = Net::Telnet->new(-host => 'localhost', -port => 25, -errmode => 'return') or die "Port not available\n"; my $rtn = $tel->getline() or die "No Reponse\n"; print $rtn =~ /^2\d\d .*SMTP/ ? 'OK' : 'Fail';