On Thu, Nov 4, 2010 at 9:50 AM, Agnello George <agnello.dso...@gmail.com>wrote:

> 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 = '' || 'sys...@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 n...@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
>
> [r...@localhost scripts]# perl  sendmemail.pl -t agnello.dso...@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:<sys...@server1.com>
> Net::SMTP=GLOB(0x8fc86ac)<<< 250 2.1.0 Ok
> Net::SMTP=GLOB(0x8fc86ac)>>> RCPT TO:<agnello.dso...@gmail.com>
> 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
>

Hi Agnello,

Maybe have a short look at the following document:
http://www.answersthatwork.com/Download_Area/ATW_Library/Networking/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 –*
*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 “221 Goodbye” or*
*“221 Closing connection”, or the most irritating one we’ve*
*seen “221 Bye”, Arrrgghh – 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 : “221 Thank you for*
*your business” (I love that one!), or “221 All messages*
*processed successfully in this session, SMTP connection*
*is closing”.*

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 tweak
but as far as I can tell you are doign everything right on the perl end.

Regards,

Rob

Reply via email to