jlongino has asked for the wisdom of the Perl Monks concerning the following question:
I'm not sure if this is a documentation bug or if I've come across a special case. I hit a snag when trying to relay MIME::Lite send error mesasages. If I have a malformed "To: " address such as in the following snippet:
The correct address should be of the form '"some name" <anyone@somewhere.com>'. In the above code the program dies with an smtp message but does not display the intended die message. The statement is patterned after the MIME::Lite documentation example:sub Send_Msg { my ($to, $from, $subject, $body) = @_; use MIME::Lite; my $msg = new MIME::Lite To => '"some name" anyone@somewhere.com', From => $from, Subject => $subject, Type => 'TEXT', Data => $body; MIME::Lite->send('smtp', "some_valid_smtp_server_name", Timeout=>6 +0); ## the following is the offending statement $msg->send || die "MIME::Lite->send failed: $!\n"; }
As an instance method with no arguments, sends the message by the default mechanism set up by the class method. Returns whatever the mail-handling routine returns: this should be true on success, false/exception on error:
However replacing the offending line with the following works correctly:$msg = MIME::Lite->new(From=>...); $msg->send || die "you DON'T have mail!";
Does this reflect your experience and if so, is it worth notifying the module author? Thanks.eval { $msg->send }; die "MIME::Lite->send failed: $@\n" if $@;
--Jim
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: MIME::Lite error handling
by robartes (Priest) on Feb 28, 2003 at 22:21 UTC | |
Re: MIME::Lite error handling
by Anonymous Monk on Oct 12, 2011 at 05:54 UTC | |
by Anonymous Monk on Feb 03, 2016 at 08:23 UTC |
Back to
Seekers of Perl Wisdom