use strict; use IO::Socket; my $sock = IO::Socket::INET->new( PeerAddr => '127.0.0.1', PeerPort => '25', Proto => 'tcp', Type => SOCK_STREAM ); do_mail($sock); print $sock "quit\n"; close($sock); sub do_mail { my($handle) = shift; my $buf = <$handle>; print "Sendmail ", $buf ? "is OK\n" : "is not responding\n"; }