I have the following script (code) to send a simple message via mail:

           

            my $sender = new Mail::Sender {

                 smtp => 'emc.com',

                 from => '[EMAIL PROTECTED]',

                 undef,

         }

                 or die "Can't create the Mail::Sender object: $Mail::Sender::Error\n";

                

         $sender->Open({

                 to => '[EMAIL PROTECTED]',

                 subject => 'Sorry, I\'ll come later.'

         })

                 or die "Can't open the message: $sender->{'error_msg'}\n";

         $sender->SendLineEnc("I'm sorry, .......,.");

         $sender->SendLineEnc("\nHi, .....");

         $sender->Close()

                or die "Failed to send the message: $sender->{'error_msg'}\n";

 

            I get the following error where connection fails, I made sure that the SMTP port is 25, any idea how to go about this:

            Can't open the message: connect() failed: A connection attempt failed because

        the connected party did not properly respond after a period of time, or

established connection failed because connected host has failed to respond (#1)

    (S inplace) The implicit opening of a file through use of the < < >>

    filehandle, either implicitly under the -n or -p command-line

    switches, or explicitly, failed for the indicated reason.  Usually this

    is because you don't have read permission for a file which you named on

    the command line.

 

Uncaught exception from user code:

        Can't open the message: connect() failed: A connection attempt failed b

cause the connected party did not properly respond after a period of time, or e

tablished connection failed because connected host has failed to respond

 

            Looks like connection fails, any idea why

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Satish Kumar
Sent:
Tuesday, May 25, 2004 4:08 AM
To: [EMAIL PROTECTED]
Subject: Re: Perl Script to send mail with Attachment

 

 

Sorry for Delay in reply...

 

Im able to send mails ,but when i send an attachment im getting below error..

 

Undefined subroutine &Mail::Sender::encode_qp called at c:/Perl/lib/Mail/Sender.pm line 792, <GEN0> line 6.

 

here is my code:

 

use MIME::Base64;

#sender.pm it is mentioned i should add this line if sendfile or  mailfile is used

use MIME::QuotedPrint;

#sender.pm it is mentioned i should add this line if sendfile or  mailfile is used

use Mail::Sender;

 $sender = new Mail::Sender
  {smtp => 'domain.com', from => '[EMAIL PROTECTED]'};
 $sender->MailFile({to => '[EMAIL PROTECTED]',cc => '[EMAIL PROTECTED]',
  subject => 'Here is the file',
  msg => "I'm sending you the list you wanted.",
  encoding => "Quoted-printable",

#sender.pm it is mentioned i should add this line...
  file => 'test.txt'});

 

 

Please help.....

 


Alexander Apprich <[EMAIL PROTECTED]> wrote:

Hi Satish,

Satish Kumar wrote:
> Hi ScriptKings,
>
> Im a newbie in Perl,
>
> Would like to know following Info:
>
> Can we create
>
> *Perl Scipt to send Mails with Attachments*
>
> Any Tips, Help, Code,Suggestions & Guidance are Welcome
>

The module Mail::Sender is probaply what you are looking for...

This is a subroutine I use to send a logfile from a Windows-Box.

sub SendMail {
# What mail error or okay?
my ( $Action );
( $Action ) = @_;
if ( $Action eq "ERROR" ) {
$note = "ALERT: blablabla";
} elsif ( $Action eq "OKAY" ) {
$note = "NOTE: blablabla";
}
$Msg = "See attached file for more details.\n";
if ( $Sender = Mail::Sender->new( {smtp => 'scmail',
from => 'serv-int'} ) ) {
} else {
End ( "FAILED" );
}
if ( $Sender->MailFile( { to => 'apprich',
subject => "$note",
msg => "$Msg",
file => "$LogFile"} ) ) {
}
}


>
> Regards,
> Satish

HTH

Alex


Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger


Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to