LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-12-2014, 08:07 PM   #1
2buck56
Member
 
Registered: Oct 2004
Posts: 54

Rep: Reputation: 15
Can't send email via SMTP on CentOS


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?
 
Old 10-13-2014, 05:31 AM   #2
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 665

Rep: Reputation: Disabled
503 need MAIL before RCPT

this is in turn coming in sequence with 530.. check your auth failures ???
 
Old 10-15-2014, 10:21 PM   #3
2buck56
Member
 
Registered: Oct 2004
Posts: 54

Original Poster
Rep: Reputation: 15
Smile

Sorry for taking so long to come back with a comment. It turned out to be a Perl issue. The newer version of Perl (5.10) needs to have the Authen::SASL module installed for the authentication to work. Either that or I had installed the Authen::SASL module on the old version (5.08) that was running on my Fedora 11 box. I can't remember as it has been too many years since I set the old server up.

All is good now and I am able to send mail to my email service provider.
 
Old 10-16-2014, 02:12 AM   #4
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 665

Rep: Reputation: Disabled
please mark as SOLVED
 
Old 10-18-2014, 12:24 PM   #5
2buck56
Member
 
Registered: Oct 2004
Posts: 54

Original Poster
Rep: Reputation: 15
One other thing I forgot to mention. The reason the telnet session did not work is because after I connected to the server, I needed to enter the command AUTH LOGIN. The server then sends a Base64 encrypted string asking for username. I had to reply with Base64 encrypted username. Server then sends a Base64 encrypted string asking for password. I had to reply with Base64 encrypted password.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command based email client to send email through secure smtp havolinec Linux - Newbie 2 07-27-2010 08:40 AM
Net::SMTP help, cant send email hawk__0 Programming 5 01-08-2010 08:44 PM
Send email to specific SMTP servers per email from my server? neilius Linux - Server 6 06-25-2009 07:31 AM
Can't send email using SMTP...stuck smiley_lauf Linux - Newbie 4 01-31-2006 09:20 PM
can't send email, smtp or sendmail dtra Linux - Software 1 11-19-2005 07:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration