ashok.g has asked for the wisdom of the Perl Monks concerning the following question:

Hi folks,

I am having problem with Mail::Sender module. Below is the code that I have been using to send an email using local smtp server.

use Mail::Sender; eval { $sender= new Mail::Sender{smtp=>'localhost'}; $sender->OpenMultipart({ to => 'emailaddress', subject => 'Provisioning Status', multipart => 'mixed', from =>'emailaddress' }); $sender->Part({ctype => 'text/html', disposition => 'NONE', msg => 'Te +st email'}); $sender->EndPart("multipart/alternative"); $sender->Close(); } or print "Error in sending mail: $Mail::Sender::Error\n"; print "Mail sent OK.\n\n";
When I run the script for 1st time its gives the following message after taking long time and no email is fired....
[ncoadmin@station28 Cox_CMDB]$ perl /tmp/sendmail.pl Mail sent OK.
after running it again I got the below message after long time
[ncoadmin@station28 Cox_CMDB]$ perl /tmp/sendmail.pl Error in sending mail: Connection not established Mail sent OK.
Any ideas on this?

Replies are listed 'Best First'.
Re: Problem with Mail::Sender module
by marto (Cardinal) on Nov 18, 2011 at 10:22 UTC

    As we already discussed in the CB consider reading the module documentation and enabling debugging.

    Update: Also consider talking the appropriate network/systems administrator.

      marto, Thanks for your suggestion. I have enabled debug and see the following information in the debug file
      >> 250 2.1.0 <someid>... Sender ok << RCPT TO:<someid> >> 250 2.1.5 <someid>... Recipient ok (will queue) << DATA >> 354 Enter mail, end with "." on a line by itself << To: someid << From: someid << Reply-to: someid << Subject: Provisioning Status << Date: Wed, 23 Nov 2011 11:48:32 +0530 << X-Mailer: Perl script "sendmail.pl" << using Mail::Sender 0.8.16 by Jenda Krynicky, Czechlands << running on station28 () << under account "ncoadmin" << Message-ID: <20111123_061832_062548.someid> << MIME-Version: 1.0 << Content-type: multipart/mixed; << boundary="Message-Boundary-by-Mail-Sender-1322028872" << << This message is in MIME format. Since your mail reader does not und +erstand << this format, some or all of this message may not be legible. << << --Message-Boundary-by-Mail-Sender-1322028872 << Content-type: text/html << Content-transfer-encoding: 7BIT << << Test email << --Message-Boundary-by-Mail-Sender-1322028872-- << << . >> 250 2.0.0 pAN6EWQt009431 Message accepted for delivery << QUIT >> 221 2.0.0 station28 closing connection
      So, it says
      Message accepted for delivery << QUIT
      Can we confirm that the email is fired? If so, what can be the reasons that email is not showing in my inbox?

        Why don't you check the mail server and see why it's not sending the mail?