perlquestion
kcantrel
Environment:<br>
O/S: Windows 7 64 bit<br>
Perl: ActivePerl 5.16.3<br>
<br>
Problem:<br>
I can't seem to get Net::SMTP to work. It fails to even attempt to connect to the mail server. I confirmed that by using 'wireshark' and noticed that no packets are leaving my computer. Here is the very basic code I am trying to use:
<code>
use strict;
use warnings;
use Net::SMTP;
use Net::FTP;
my $server = "cube";
my $smtp = Net::SMTP->new(Host => $server, Debug => 1, Timeout => 60);
#my $smtp = Net::FTP->new($server, Debug => 1);
if(!defined($smtp)) {
die "Failed to connect to $server\n";
}
print $smtp->domain,"\n";
$smtp->quit;
</code>
<p>
In the above code the call to Net::SMTP->New() always returns "undef". You can see where I tried "Net::FTP" and that one works just fine, so the underlying network routines seem to work. I also confirmed I can telnet to port 25 of the mail server, and I get the typical "welcome" response. I've tried various options and ways of calling SMTP->new but they all result in the same problem. Any ideas will be greatly appreciated.
</p>
A slight update, I just added "($!; $@)" to the die line above and it printed:<br>
Failed to connect to cube (No connection could be made because the target machine actively refused it.; Net::SMTP: connect: No connection could be made because the target machine actively refused it.)<br>
Keep in mind that I saw NO network activity with Wireshark and 'telnet' is able to connect to port 25. Oh, and I have disabled the Windows Firewall. So, in my option the error message is misleading at best.