After reading the docs for the module I can find a way to manage an
exception thrown by the send method when the mailhost is down. The
program dies with the error "Failed to connect to mail server: Invalid
argument". Is there a way to trap this error and let the program
continue?  I would think that this should possible and I am not seeing
the obvious answer. Any recommendation would be appreciated.

Simply change $mailhost to a non-existent SMTP host to test.

use strict;
use MIME::Lite;

my $mailhost =  'mailhost.domain.com';

my $msg = MIME::Lite->new(
             From    =>'[EMAIL PROTECTED]',
             To      =>'[EMAIL PROTECTED]',
             Subject =>'test',
             Type    =>'TEXT/HTML',
             Data    =>'Test text'
             );

MIME::Lite->send('smtp', $mailhost , Timeout=>60);
if ($msg->send) {
    print "message sent\n";
}
else {
    print "Failed to send\n";
}
print "last line\n";

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to