I didn't know whether to post this on a Perl forum or Unix forum. However, I decided Unix is best since this appears to be an OS related issue.
For the last several years I have ran Fedora 11. I have a Perl script script that sends me an email each morning to tell me the current IP address of my WAN connection. This is in case the ISP changes the IP (happens about once per year). That way if I am on the road I can still access my home network through my firewall. This script has worked flawlessly until now.
Yesterday I replaced the Fedora 11 install with a CentOS 6.5 install. Now the Perl script doesn't send email. Below is the script and ouput of running the script (aliases used for post).
Script:
#!/usr/bin/perl
use warnings;
use strict;
use Net::SMTP;
my $networkinfo = `ifconfig eth0 |grep inet`;
my $ipinfo = substr($networkinfo, 20, 15);
my $message = `date`;
my $smtpserver = 'smtpout.secureserver.net';
my $smtpport = 3535;
my $smtpuser = 'me@xxxxxxx.com';
my $smtppasswd = 'PASSWORD';
my $smtp = Net::SMTP->new($smtpserver, Port=>$smtpport, Timeout=>5, Debug=>1);
die "Could not connect to server!\n" unless $smtp;
$smtp->auth($smtpuser, $smtppasswd);
$smtp->mail('rbuck@xxxxxxx.com');
$smtp->to('rbuck@xxxxxxx.com');
$smtp->data();
$smtp->datasend("To: raybuck\@yyyyyyyyy.com\n");
$smtp->datasend("To: rbuck\@xxxxxxxx.com\n");
$smtp->datasend("From: rbuck\@xxxxxxxx.com\n");
# \n has to be at end of Subject: line for message body to display in email
$smtp->datasend("Subject: Server IP\n");
$smtp->datasend("\n");
$smtp->datasend("The XYZ server is up: $message\n");
$smtp->datasend("Server IP: $ipinfo");
#$smtp->datasend();
$smtp->quit;
Output from running script:
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.63)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.31)
Net::SMTP>>> IO::Handle(1.28)
Net::SMTP=GLOB(0x1ff9490)<<< 220 p3plsmtpa09-10.prod.phx3.secureserver.net ESMTP
Net::SMTP=GLOB(0x1ff9490)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x1ff9490)<<< 250-p3plsmtpa09-10.prod.phx3.secureserver.net hello [68.231.73.208], secureserver.net
Net::SMTP=GLOB(0x1ff9490)<<< 250-HELP
Net::SMTP=GLOB(0x1ff9490)<<< 250-AUTH LOGIN PLAIN
Net::SMTP=GLOB(0x1ff9490)<<< 250-SIZE 31457280
Net::SMTP=GLOB(0x1ff9490)<<< 250-PIPELINING
Net::SMTP=GLOB(0x1ff9490)<<< 250-8BITMIME
Net::SMTP=GLOB(0x1ff9490)<<< 250 OK
Net::SMTP=GLOB(0x1ff9490)>>> MAIL FROM:<rbuck@xxxxxxx.com>
Net::SMTP=GLOB(0x1ff9490)<<< 530 authentication required
Net::SMTP=GLOB(0x1ff9490)>>> RCPT TO:<rbuck@xxxxxxx.com>
Net::SMTP=GLOB(0x1ff9490)<<< 503 need MAIL before RCPT
Net::SMTP=GLOB(0x1ff9490)>>> DATA
Net::SMTP=GLOB(0x1ff9490)<<< 503 need MAIL before DATA
Net::SMTP=GLOB(0x1ff9490)>>> To:
raybuck@yyyyyyy.com
Net::SMTP=GLOB(0x1ff9490)>>> To:
rbuck@xxxxxxx.com
Net::SMTP=GLOB(0x1ff9490)>>> From:
rbuck@xxxxxxx.com
Net::SMTP=GLOB(0x1ff9490)>>> Subject: Server IP
Net::SMTP=GLOB(0x1ff9490)>>> The XYZ server is up: Sun Oct 12 15:57:14 MST 2014
Net::SMTP=GLOB(0x1ff9490)>>> Server IP: xx.xxx.xx.xxx
Net::SMTP=GLOB(0x1ff9490)>>> .
Net::SMTP=GLOB(0x1ff9490)<<< 500 command unrecognized
Net::SMTP=GLOB(0x1ff9490)>>> QUIT
Net::SMTP=GLOB(0x1ff9490)<<< 500 command unrecognized
Why would changing the OS break the script? Why is the 503 need MAIL before RCPT error being generated. You can plainly see the $smtp->mail in the script. Also, why is the 530 authentication required error being generated when I have already connected to the SMPT server and authenticated?
Nothing has changed in the script. I just copied it from the old server to the new server.
This is the output from a telnet session to the mail server:
[rbuck@ATC-Network ~]$ telnet smtpout.secureserver.net 3535
Trying 173.201.193.101...
Connected to smtpout.secureserver.net.
Escape character is '^]'.
220 p3plsmtpa08-07.prod.phx3.secureserver.net ESMTP
ehlo atcelectronics
250-p3plsmtpa08-07.prod.phx3.secureserver.net hello [xx.xxx.xx.xxx], secureserver.net
250-HELP
250-AUTH LOGIN PLAIN
250-SIZE 31457280
250-PIPELINING
250-8BITMIME
250 OK
mail from:rbuck@xxxxxxx.com
530 authentication required
rcpt to:rbuck@xxxxxxx.com
503 need MAIL before RCPT
Connection closed by foreign host.
So a telnet session no long works on the CentOS system. It worked on the Fedora 11 system. I have searched internet and tried several things but no luck. This is why I said at the beginning that I think it is OS related.
Anyone have suggestions?