I use MIME::Lite for sending email from my programs. If the mail server
can not be contacted the following MIME::Lite code causes a fatal error
aborting my process.

### Create SMTP client:
require Net::SMTP;
my $smtp = MIME::Lite::SMTP->new(@args)
    or Carp::croak("Failed to connect to mail server: $!\n");
$smtp->mail($from)
    or Carp::croak("SMTP MAIL command failed:
$!\n".$smtp->message."\n");
$smtp->to(@to_all)
    or Carp::croak("SMTP RCPT command failed:
$!\n".$smtp->message."\n");
$smtp->data()
    or Carp::croak("SMTP DATA command failed:
$!\n".$smtp->message."\n");


I tried to trap this issue in my code using "eval", but was
unsuccessful.

if (eval {$msg->send}) {
    print "message sent\n";
}
else {
    print "Failed to send: [EMAIL PROTECTED]";
}

Did I use the eval improperly or is there a better to prevent the
stopping of my process?
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to