Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Error handling with MIME::Lite

by jlongino (Parson)
on Sep 11, 2002 at 06:02 UTC ( [id://196872]=note: print w/replies, xml ) Need Help??


in reply to Error handling with MIME::Lite

After some experimentation, it looks as though this might be your best bet assuming you don't want to use any extra modules:
MIME::Lite->send('smtp', $SmtpServer, Timeout=>60); eval { $msg->send }; print $@ if $@; ### or do_something() if $@;
This will trap the errors and allow you to continue processing but it doesn't tell you if $SmtpServer is invalid. An invalid host would return a message something like this:
Failed to connect to mail server: Invalid argument at mime.lite.p line ##
If the $SmtpServer doesn't allow relaying, you might get a message like this:
SMTP RCPT command failed:
What if the server times out? If you need to do more extensive error testing you might want to try using something like Net::SMTP, which is a subclass of Net::Cmd and IO::Socket::INET to send the message.

--Jim

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://196872]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found