LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-28-2014, 05:19 AM   #1
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Rep: Reputation: Disabled
run perl module error


I want to create a perl function for sending mail, I have successfully installed the perl module Net::SMTP .

When I run the below script but got the below errors , would advise what is wrong in my case ? thanks

Code:
my script
============

#!/usr/bin/perl
use warnings;
use strict;
use Net::SMTP;

my $smtpserver = 'localhost';
my $smtpport = 25;
my $smtpuser   = 'user';
my $smtppassword = 'password';

my $smtp = Net::SMTP->new($smtpserver, Port=>$smtpport, Timeout => 10, Debug => 1);
die "Could not connect to server!\n" unless $smtp;

$smtp->auth($smtpuser, $smtppassword);
$smtp->to('jpdees@gmail.com');
$smtp->data();
$smtp->datasend("To: mymail\@gmail.com\n");
$smtp->quit;
Code:
run script error 
================

Net::SMTP>>> Net::SMTP(2.33)
Net::SMTP>>>   Net::Cmd(2.30)
Net::SMTP>>>     Exporter(5.58)
Net::SMTP>>>   IO::Socket::INET(1.29)
Net::SMTP>>>     IO::Socket(1.29)
Net::SMTP>>>       IO::Handle(1.25)
Net::SMTP=GLOB(0x10398490)<<< 220 localhost.localdomain ESMTP Sendmail ; Mon, 28 Apr 2014 17:16:22 +0800
Net::SMTP=GLOB(0x10398490)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x10398490)<<< 250-localhost.localdomain Hello localhost.localdomain [127.0.0.1], pleased to meet you
Net::SMTP=GLOB(0x10398490)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x10398490)<<< 250-PIPELINING
Net::SMTP=GLOB(0x10398490)<<< 250-8BITMIME
Net::SMTP=GLOB(0x10398490)<<< 250-SIZE 20000000
Net::SMTP=GLOB(0x10398490)<<< 250-DSN
Net::SMTP=GLOB(0x10398490)<<< 250-ETRN
Net::SMTP=GLOB(0x10398490)<<< 250-DELIVERBY
Net::SMTP=GLOB(0x10398490)<<< 250 HELP
Net::SMTP=GLOB(0x10398490)>>> RCPT TO:<jpdees@gmail.com>
Net::SMTP=GLOB(0x10398490)<<< 503 5.0.0 Need MAIL before RCPT
Net::SMTP=GLOB(0x10398490)>>> DATA
Net::SMTP=GLOB(0x10398490)<<< 503 5.0.0 Need MAIL command
Net::SMTP=GLOB(0x10398490)>>> To: mymail@gmail.com
Net::SMTP=GLOB(0x10398490)>>> .
Net::SMTP=GLOB(0x10398490)<<< 500 5.5.1 Command unrecognized: "To: mymail@gmail.com"
Net::SMTP=GLOB(0x10398490)>>> QUIT
Net::SMTP=GLOB(0x10398490)<<< 500 5.5.1 Command unrecognized: "."
Code:
maillog error
==============
s3S9GMHo009143: localhost.localdomain [127.0.0.1] did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA

Last edited by byran cheung; 04-28-2014 at 05:20 AM.
 
Old 04-28-2014, 06:24 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 979
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
Your error
Quote:
did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA
is a clue ... looks like you are missing
Code:
smtp->mail("sender\@example.com");
 
Old 04-28-2014, 12:14 PM   #3
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Original Poster
Rep: Reputation: Disabled
thanks reply ,

I changed to as below , but still get the error , would advise what is wrong ?

Code:
my script
=========
my $smtpserver = 'localhost';
my $smtpport = 25;
my $smtpuser   = 'user';
my $smtppassword = 'password';

my $smtp = Net::SMTP->new($smtpserver, Port=>$smtpport, Timeout => 10, Debug => 1);
die "Could not connect to server!\n" unless $smtp;

$smtp->auth($smtpuser, $smtppassword);
$smtp->to('jpdees@gmail.com');
$smtp->data();
$smtp->datasend("To: jpdees\@gmail.com\n");
$smtp->mail("sender\@example.com");
$smtp->quit;
Code:
run error
========== 
Net::SMTP=GLOB(0x198944e0)<<< 250-PIPELINING
Net::SMTP=GLOB(0x198944e0)<<< 250-8BITMIME
Net::SMTP=GLOB(0x198944e0)<<< 250-SIZE 20000000
Net::SMTP=GLOB(0x198944e0)<<< 250-DSN
Net::SMTP=GLOB(0x198944e0)<<< 250-ETRN
Net::SMTP=GLOB(0x198944e0)<<< 250-DELIVERBY
Net::SMTP=GLOB(0x198944e0)<<< 250 HELP
Net::SMTP=GLOB(0x198944e0)>>> RCPT TO:<jpdees@gmail.com>
Net::SMTP=GLOB(0x198944e0)<<< 503 5.0.0 Need MAIL before RCPT
Net::SMTP=GLOB(0x198944e0)>>> DATA
Net::SMTP=GLOB(0x198944e0)<<< 503 5.0.0 Need MAIL command
Net::SMTP=GLOB(0x198944e0)>>> To: jpdees@gmail.com
Net::SMTP=GLOB(0x198944e0)>>> .
Net::SMTP=GLOB(0x198944e0)<<< 500 5.5.1 Command unrecognized: "To: jpdees@gmail.com"
Net::SMTP=GLOB(0x198944e0)>>> MAIL FROM:<sender@example.com>
Net::SMTP=GLOB(0x198944e0)<<< 500 5.5.1 Command unrecognized: "."
Net::SMTP=GLOB(0x198944e0)>>> QUIT
Net::SMTP=GLOB(0x198944e0)<<< 250 2.1.0 <sender@example.com>... Sender ok
Code:
/var/log/maillog
=================
sendmail[9355]: s3SG4svF009355: from=<sender@example.com>, size=0, class=0, nrcpts=0, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]

Last edited by byran cheung; 04-28-2014 at 12:16 PM.
 
Old 04-28-2014, 12:21 PM   #4
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 979
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
error message says
Quote:
Need MAIL before RCPT
need
Code:
$smtp->mail("sender\@example.com");
before
Code:
->to
 
Old 04-28-2014, 12:50 PM   #5
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Original Poster
Rep: Reputation: Disabled
thanks reply ,

I still not get the mail , but from the maillog shown that the mail has been successfully sent , I will check my smtp first .

another question , what is the below smtpuser stands for , do I need to input any user id to it ?

my $smtpuser = 'user';
my $smtppassword = 'password';


thanks
 
Old 04-28-2014, 01:04 PM   #6
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 979
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
These appear in the code as
Code:
$smtp->auth($smtpuser, $smtppassword);
so if you aren't using real values there I'd drop that line.
 
Old 04-28-2014, 01:10 PM   #7
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by linosaurusroot View Post
These appear in the code as
Code:
$smtp->auth($smtpuser, $smtppassword);
so if you aren't using real values there I'd drop that line.
what is the real values , is it linux login ID or smtp ID ? thanks
 
Old 04-28-2014, 01:19 PM   #8
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Original Poster
Rep: Reputation: Disabled
I just check the maillog and found that the mail is relay to another smtp server , not relay to localhost ( relay=[127.0.0.1] ) , I found that the mail sent from this server was use localhost relay , but this perl script relay another smtp server , would advise what is the problem ? thanks
 
Old 04-29-2014, 03:39 AM   #9
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Original Poster
Rep: Reputation: Disabled
hi ,

My final version of script is below , but I can't get the mail , when use sendmail to send , it is OK .

I checked the maillog , everything seems normal ( I tried to use sendmail to send mail , the log is similiar ) .

Would advise what will be the possible of the error ? thanks

#!/usr/bin/perl
use warnings;
use strict;
use Net::SMTP;

my $smtpserver = 'localhost';
my $smtpport = 25;
my $smtpuser = 'username';
my $smtppassword = 'password';

my $smtp = Net::SMTP->new($smtpserver, Port=>$smtpport, Timeout => 10, Debug => 1);
die "Could not connect to server!\n" unless $smtp;

#$smtp->auth($smtpuser, $smtppassword);
$smtp->mail("amy\@localhost.localdomain");
$smtp->to('dusse@gmail.com');
$smtp->data();
$smtp->datasend("To: dusse\@gmail.com\n");
$smtp->quit;
 
  


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
[SOLVED] *** ERROR: PERL module Apache::DBI is not installed ! anjumanu321 Linux - Newbie 9 04-23-2015 04:40 PM
Error installing MySQL perl module Metropolis Linux - Software 3 10-22-2009 10:49 AM
list perl module & install perl module DBD::mysql linson_85 Linux - Newbie 4 06-22-2009 11:42 AM
error compiling a perl module? waelaltaqi Linux - Software 2 03-15-2008 03:12 PM
perl Module error; DanTaylor Programming 5 02-03-2006 12:54 PM


All times are GMT -5. The time now is 02:49 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration