use IO::Socket; chop (my $hostname = `hostname`); my $sock = new IO::Socket::INET ( PeerAddr => '10.106.2.43:25', LocalAddr => $hostname, Proto => 'tcp') || die "cant create socket$@\n"; print $sock "helo $hostname\n"; ($result = <$sock>); print $result."\n\n"; $sock->flush; print $sock "helo $hostname\n"; ($result = <$sock>); print $result."\n\n"; #### 220 ildmailw102p Microsoft ESMTP MAIL Service, Version: 7.5.7601.17514 ready at Tue, 1 Jul 2014 14:48:19 -0400