Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Sending SMTP mail on other than port 25

by projekt21 (Friar)
on Apr 26, 2002 at 10:43 UTC ( [id://162237]=note: print w/replies, xml ) Need Help??


in reply to Sending SMTP mail on other than port 25

Looking at Net::SMTP I found the following within sub new

$obj = $type->SUPER::new(PeerAddr => ($host = $h), PeerPort => $arg{Port} || 'smtp(25)', Proto => 'tcp', Timeout => defined $arg{Timeout} ? $arg{Timeout} : 120 ) and last;

Without any further research I would guess that you may try:

my $s = Net::SMTP->new( $host, Port => $port );

alex pleiner <alex@zeitform.de>
zeitform Internet Dienste

Replies are listed 'Best First'.
Re:x2 Sending SMTP mail on other than port 25
by grinder (Bishop) on Apr 26, 2002 at 12:51 UTC

    ok, so I have the solution and I'm pleased to say that it works. Next time I'll try to remember to RTFS.

    It makes me think, though, that the interface is slightly broken. To construct an object of the class correctly, it needs to pass a named attribute X to a base class. You can't, however, pass the X attribute to the new() method directly, only X2 is allowed.

    I read the Net::SMTP pod, and no mention is made of the Port attribute (which is sort of to be expected). So from there I followed the chain of pod to Net::Cmd, IO::Handle, IO::Socket and IO::Socket::INET, which is where I finally found a mention a mention of PeerPort. In the first instance I was using Peer_Port, which didn't work, so when I came across this, I was sure it would work.

    So what really needs to happen is the line PeerPort => $arg{Port} || 'smtp(25)',

    ...needs to be written as...

    PeerPort => $arg{PeerPort} || $arg{Port} || 'smtp(25)',

    and that way it will work regardless. I'll see what gbarr think about this :)


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://162237]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-03-29 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found