using Net::SMTP unable to send out a mail

using Net::SMTP unable to send out a mail

am 04.11.2010 09:50:12 von Agnello George

--000e0cd150b6f305fa0494363e82
Content-Type: text/plain; charset=ISO-8859-1

HI

i wrote a small simple script using Net::smtp however my local MTA is not
accepting the mail here is the script :


=================================================

#!/usr/bin/perl

use strict;
use warnings;
use Net::SMTP;
use Getopt::Long;

my $from = '' || 'system@server1.com' ;
my $sub = '' || 'this is a testmail';
my $content = '' || 'this is a data';
my $to;
my $relayhost = '' || 'localhost';


GetOptions(
'from|f=s' => \$from ,
'to|t=s' => \$to,
'sub|s=s' => \$sub ,
'content|c=s' => \$content,
'relayhost|h=s' => \$relayhost );

die 'usage: sendmemail.pl--to name@email.com' unless( $to );


my $smtp = Net::SMTP->new("$relayhost",
Debug => 1,
);
$smtp->mail($from);
$smtp->to($to);
$smtp->datasend("Subject: $sub");
$smtp->datasend("\n");
$smtp->datasend("$content\n");
$smtp->dataend();
$smtp->quit();

============================================================ ========================

i am getting the following error while executing the script

[root@localhost scripts]# perl sendmemail.pl -t agnello.dsouza@gmail.com
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.62)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.30_01)
Net::SMTP>>> IO::Handle(1.27)
Net::SMTP=GLOB(0x8fc86ac)<<< 220 localhost.localdomain ESMTP Postfix
Net::SMTP=GLOB(0x8fc86ac)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x8fc86ac)<<< 250-localhost.localdomain
Net::SMTP=GLOB(0x8fc86ac)<<< 250-PIPELINING
Net::SMTP=GLOB(0x8fc86ac)<<< 250-SIZE 10240000
Net::SMTP=GLOB(0x8fc86ac)<<< 250-VRFY
Net::SMTP=GLOB(0x8fc86ac)<<< 250-ETRN
Net::SMTP=GLOB(0x8fc86ac)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x8fc86ac)<<< 250-8BITMIME
Net::SMTP=GLOB(0x8fc86ac)<<< 250 DSN
Net::SMTP=GLOB(0x8fc86ac)>>> MAIL FROM:
Net::SMTP=GLOB(0x8fc86ac)<<< 250 2.1.0 Ok
Net::SMTP=GLOB(0x8fc86ac)>>> RCPT TO:
Net::SMTP=GLOB(0x8fc86ac)<<< 250 2.1.5 Ok
Net::SMTP=GLOB(0x8fc86ac)>>> Subject: this is a testmail
Net::SMTP=GLOB(0x8fc86ac)>>> this is a data
Net::SMTP=GLOB(0x8fc86ac)>>> .
Net::SMTP=GLOB(0x8fc86ac)<<< 221 2.7.0 Error: I can break rules, too.
Goodbye.
Net::SMTP=GLOB(0x8fc86ac)>>> QUIT
Net::SMTP: Unexpected EOF on command channel at sendmemail.pl line 34



your help will be of much value .

Thanks

--
Regards
Agnello D'souza

--000e0cd150b6f305fa0494363e82--

Re: using Net::SMTP unable to send out a mail

am 04.11.2010 10:10:49 von Rob Coops

--20cf300515caeb4ec00494368967
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Thu, Nov 4, 2010 at 9:50 AM, Agnello George wr=
ote:

> HI
>
> i wrote a small simple script using Net::smtp however my local MTA is no=
t
> accepting the mail here is the script :
>
>
> ==================== =====
==================== =====3D
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> use Net::SMTP;
> use Getopt::Long;
>
> my $from =3D '' || 'system@server1.com' ;
> my $sub =3D '' || 'this is a testmail';
> my $content =3D '' || 'this is a data';
> my $to;
> my $relayhost =3D '' || 'localhost';
>
>
> GetOptions(
> 'from|f=3Ds' =3D> \$from ,
> 'to|t=3Ds' =3D> \$to,
> 'sub|s=3Ds' =3D> \$sub ,
> 'content|c=3Ds' =3D> \$content,
> 'relayhost|h=3Ds' =3D> \$relayhost );
>
> die 'usage: sendmemail.pl--to name@email.com' unless( $to );
>
>
> my $smtp =3D Net::SMTP->new("$relayhost",
> Debug =3D> 1,
> );
> $smtp->mail($from);
> $smtp->to($to);
> $smtp->datasend("Subject: $sub");
> $smtp->datasend("\n");
> $smtp->datasend("$content\n");
> $smtp->dataend();
> $smtp->quit();
>
>
> ==================== =====
==================== =====3D=
==================== =====3D=
==========
>
> i am getting the following error while executing the script
>
> [root@localhost scripts]# perl sendmemail.pl -t agnello.dsouza@gmail.com
> Net::SMTP>>> Net::SMTP(2.31)
> Net::SMTP>>> Net::Cmd(2.29)
> Net::SMTP>>> Exporter(5.62)
> Net::SMTP>>> IO::Socket::INET(1.31)
> Net::SMTP>>> IO::Socket(1.30_01)
> Net::SMTP>>> IO::Handle(1.27)
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 220 localhost.localdomain ESMTP Postfix
> Net::SMTP=3DGLOB(0x8fc86ac)>>> EHLO localhost.localdomain
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-localhost.localdomain
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-PIPELINING
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-SIZE 10240000
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-VRFY
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-ETRN
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-ENHANCEDSTATUSCODES
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-8BITMIME
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250 DSN
> Net::SMTP=3DGLOB(0x8fc86ac)>>> MAIL FROM:
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250 2.1.0 Ok
> Net::SMTP=3DGLOB(0x8fc86ac)>>> RCPT TO:
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250 2.1.5 Ok
> Net::SMTP=3DGLOB(0x8fc86ac)>>> Subject: this is a testmail
> Net::SMTP=3DGLOB(0x8fc86ac)>>> this is a data
> Net::SMTP=3DGLOB(0x8fc86ac)>>> .
> Net::SMTP=3DGLOB(0x8fc86ac)<<< 221 2.7.0 Error: I can break rules, too.
> Goodbye.
> Net::SMTP=3DGLOB(0x8fc86ac)>>> QUIT
> Net::SMTP: Unexpected EOF on command channel at sendmemail.pl line 34
>
>
>
> your help will be of much value .
>
> Thanks
>
> --
> Regards
> Agnello D'souza
>

Hi Agnello,

Maybe have a short look at the following document:
http://www.answersthatwork.com/Download_Area/ATW_Library/Net working/Network=
__3-SMTP_Server_Status_Codes_and_SMTP_Error_Codes.pdf

And then in particulair the following section:

*SMTP Error 221 : The server is ending the mail session â€=93*
*it is closing the conversation with the ISP as it has no more*
*mail to send in this sending session.*
*SMTP Status 221 is often misconstrued as an error*
*condition, when it is in fact nothing of the sort. The mail*
*server is simply telling you that it has processed everything*
*it was given in this particular session, and it is now going*
*back into waiting mode.*
*Because SMTP status 221 is often misinterpreted, with*
*some mail servers the Network Administrators have*
*changed the default text of SMTP Reply 221 to something*
*more meaningful and less alarming. For example, a typical*
*SMTP reply 221 might say â€=9C221 Goodbyeâ€=9D or*
*â€=9C221 Closing connectionâ€=9D, or the most irritating one we=E2=
€™ve*
*seen â€=9C221 Byeâ€=9D, Arrrgghh â€=93 can you blame anyone fo=
r*
*thinking there might be a problem ? Of course not ! So*
*some Network Administrators are these days being quite*
*imaginative by changing the default text of SMTP reply 221*
*to more user friendly messages like : â€=9C221 Thank you for*
*your businessâ€=9D (I love that one!), or â€=9C221 All messages*
*processed successfully in this session, SMTP connection*
*is closingâ€=9D.*

It looks to me like all is working fine as far as the sending of mail
goes... the only reason you might not recieve the email I can think of is
that your SMTP server would not be able to deliver the mail to the mailbox
of the recieving party because it does not have access to the mailbox or
because it cannot reach another mail relay that will be able to get the
message delivered. In short you SMTP server configuration might need a twea=
k
but as far as I can tell you are doign everything right on the perl end.

Regards,

Rob

--20cf300515caeb4ec00494368967--

Re: using Net::SMTP unable to send out a mail

am 04.11.2010 10:31:21 von Agnello George

--000e0cd32e422b4b8b049436d27b
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Thu, Nov 4, 2010 at 2:40 PM, Rob Coops wrote:

>
>
> On Thu, Nov 4, 2010 at 9:50 AM, Agnello George =
wrote:
>
>> HI
>>
>> i wrote a small simple script using Net::smtp however my local MTA is n=
ot
>> accepting the mail here is the script :
>>
>>
>> ==================== =====
==================== =====3D
>>
>> #!/usr/bin/perl
>>
>> use strict;
>> use warnings;
>> use Net::SMTP;
>> use Getopt::Long;
>>
>> my $from =3D '' || 'system@server1.com' ;
>> my $sub =3D '' || 'this is a testmail';
>> my $content =3D '' || 'this is a data';
>> my $to;
>> my $relayhost =3D '' || 'localhost';
>>
>>
>> GetOptions(
>> 'from|f=3Ds' =3D> \$from ,
>> 'to|t=3Ds' =3D> \$to,
>> 'sub|s=3Ds' =3D> \$sub ,
>> 'content|c=3Ds' =3D> \$content,
>> 'relayhost|h=3Ds' =3D> \$relayhost );
>>
>> die 'usage: sendmemail.pl--to name@email.com' unless( $to );
>>
>>
>> my $smtp =3D Net::SMTP->new("$relayhost",
>> Debug =3D> 1,
>> );
>> $smtp->mail($from);
>> $smtp->to($to);
>> $smtp->datasend("Subject: $sub");
>> $smtp->datasend("\n");
>> $smtp->datasend("$content\n");
>> $smtp->dataend();
>> $smtp->quit();
>>
>>
>> ==================== =====
==================== =====3D=
==================== =====3D=
==========
>>
>> i am getting the following error while executing the script
>>
>> [root@localhost scripts]# perl sendmemail.pl -t agnello.dsouza@gmail.co=
m
>> Net::SMTP>>> Net::SMTP(2.31)
>> Net::SMTP>>> Net::Cmd(2.29)
>> Net::SMTP>>> Exporter(5.62)
>> Net::SMTP>>> IO::Socket::INET(1.31)
>> Net::SMTP>>> IO::Socket(1.30_01)
>> Net::SMTP>>> IO::Handle(1.27)
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 220 localhost.localdomain ESMTP Postfix
>> Net::SMTP=3DGLOB(0x8fc86ac)>>> EHLO localhost.localdomain
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-localhost.localdomain
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-PIPELINING
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-SIZE 10240000
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-VRFY
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-ETRN
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-ENHANCEDSTATUSCODES
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250-8BITMIME
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250 DSN
>> Net::SMTP=3DGLOB(0x8fc86ac)>>> MAIL FROM:
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250 2.1.0 Ok
>> Net::SMTP=3DGLOB(0x8fc86ac)>>> RCPT TO:
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 250 2.1.5 Ok
>> Net::SMTP=3DGLOB(0x8fc86ac)>>> Subject: this is a testmail
>> Net::SMTP=3DGLOB(0x8fc86ac)>>> this is a data
>> Net::SMTP=3DGLOB(0x8fc86ac)>>> .
>> Net::SMTP=3DGLOB(0x8fc86ac)<<< 221 2.7.0 Error: I can break rules, too.
>> Goodbye.
>> Net::SMTP=3DGLOB(0x8fc86ac)>>> QUIT
>> Net::SMTP: Unexpected EOF on command channel at sendmemail.pl line 34
>>
>>
>>
>> your help will be of much value .
>>
>> Thanks
>>
>> --
>> Regards
>> Agnello D'souza
>>
>
> Hi Agnello,
>
> Maybe have a short look at the following document:
> http://www.answersthatwork.com/Download_Area/ATW_Library/Net working/Netwo=
rk__3-SMTP_Server_Status_Codes_and_SMTP_Error_Codes.pdf
>
> And then in particulair the following section:
>
> *SMTP Error 221 : The server is ending the mail session â€=93*
> *it is closing the conversation with the ISP as it has no more*
> *mail to send in this sending session.*
> *SMTP Status 221 is often misconstrued as an error*
> *condition, when it is in fact nothing of the sort. The mail*
> *server is simply telling you that it has processed everything*
> *it was given in this particular session, and it is now going*
> *back into waiting mode.*
> *Because SMTP status 221 is often misinterpreted, with*
> *some mail servers the Network Administrators have*
> *changed the default text of SMTP Reply 221 to something*
> *more meaningful and less alarming. For example, a typical*
> *SMTP reply 221 might say â€=9C221 Goodbyeâ€=9D or*
> *â€=9C221 Closing connectionâ€=9D, or the most irritating one we=
â€=99ve*
> *seen â€=9C221 Byeâ€=9D, Arrrgghh â€=93 can you blame anyone =
for*
> *thinking there might be a problem ? Of course not ! So*
> *some Network Administrators are these days being quite*
> *imaginative by changing the default text of SMTP reply 221*
> *to more user friendly messages like : â€=9C221 Thank you for*
> *your businessâ€=9D (I love that one!), or â€=9C221 All messages*
> *processed successfully in this session, SMTP connection*
> *is closingâ€=9D.*
>
> It looks to me like all is working fine as far as the sending of mail
> goes... the only reason you might not recieve the email I can think of is
> that your SMTP server would not be able to deliver the mail to the mailbo=
x
> of the recieving party because it does not have access to the mailbox or
> because it cannot reach another mail relay that will be able to get the
> message delivered. In short you SMTP server configuration might need a tw=
eak
> but as far as I can tell you are doign everything right on the perl end.
>
> Regards,
>
> Rob
>


Hi

I had forgotten to add ï»=BF$smtp->data(); after $smtp->to($to); so her=
e is the
corrected script .

#!/usr/bin/perl

use strict;
use warnings;
use Net::SMTP;
use Getopt::Long;

my $from =3D '' || 'system@server1.com' ;
my $sub =3D '' || 'this is a testmail';
my $content =3D '' || 'this is a data';
my $to;
my $relayhost =3D '' || 'localhost';


GetOptions(
'from|f=3Ds' =3D> \$from ,
'to|t=3Ds' =3D> \$to,
'sub|s=3Ds' =3D> \$sub ,
'content|c=3Ds' =3D> \$content,
'relayhost|h=3Ds' =3D> \$relayhost );

die 'usage: sendmemail.pl--to name@email.com' unless( $to );


my $smtp =3D Net::SMTP->new("$relayhost",
Debug =3D> 1,
);
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("Subject: $sub");
$smtp->datasend("\n");
$smtp->datasend("$content\n");
$smtp->dataend();
$smtp->quit();




--=20
Regards
Agnello D'souza

--000e0cd32e422b4b8b049436d27b--