capturing error in MIME::Lite

J

John

Hi

I have

use Net::SMTP;
use MIME::Lite;
... ... ...
MIME::Lite->send('smtp',$mail_host,TimeOut=>60);
$msg->send or die "error in email";

I thought the die would capture any error. If the email address is not
vaild I get:

Software error:
SMTP recipient() command failed:
5.1.1 <[email protected]>: Recipient address rejected: User unknown in
virtual alias table

Why isn't die capturing the error?

Regards
John
 
S

Steve C

John said:
Hi

I have

use Net::SMTP;
use MIME::Lite;
.. ... ...
MIME::Lite->send('smtp',$mail_host,TimeOut=>60);
$msg->send or die "error in email";

I thought the die would capture any error. If the email address is not
vaild I get:

Software error:
SMTP recipient() command failed:
5.1.1 <[email protected]>: Recipient address rejected: User unknown in
virtual alias table

Why isn't die capturing the error?


Presumably it is getting the error before send returns, so it never
gets to the 'or die'. Are you assuming that die does something like
try-catch in other languages? For that you want to use eval or
the TryCatch module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top