Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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'

In reply to Sending SMTP mail on other than port 25 by grinder

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2021-06-17 23:48 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (86 votes). Check out past polls.