grinder has asked for the wisdom of the Perl Monks concerning the following question:

Monks, I need to send some mail to a server that is configured to listen on other than port 25 for SMTP connections. According to Super Search no-one seems to have needed to do this yet :)

I have an antivirus package listening to port 25, and after cleaning a message of viruses, it forwards the message to another port on the same machine, where my SMTP server is listening.

I want to prove to myself that my firewall rules are set up correctly, and that it is not possible for a remote host to connect to said port, otherwise is would be possible to bypass the antivirus check.

Someone suggested Net::SMTP. Since it is derived from IO::Socket::INET, it can accept a PeerPort attribute, which would let me do what I want. Unfortunately, what I have written does not work:

#! /usr/bin/perl -w use strict; use Net::SMTP; my $host = shift || die "No host specified on command line.\n"; my $port = shift || die "No port specified on command line.\n"; my $s = Net::SMTP->new( $host, PeerPort => $port ); print $s->banner(), "\n"; $s->to( 'postmaster' ); $s->data(); $s->datasend( scalar gmtime ); $s->datasend( "\n" ); my $foo = <STDIN>; $s->dataend(); $s->quit();

While the script waits on STDIN, I can run a netstat and look for the open socket, and I see:

x.x.x.x.39394 y.y.y.y.25 8675 0 8760 0 ESTABLISHE +D

That is, the connection is opened on the port 25, not the port specified by the PeerPort attribute. I do get the banner, as double proof that the connection is connected on 25. Can someone hit me with a cluestick? Thanks.

print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'