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:
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"; }
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:
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:
$msg = MIME::Lite->new(From=>...); $msg->send || die "you DON'T have mail!";
However replacing the offending line with the following works correctly:
eval { $msg->send }; die "MIME::Lite->send failed: $@\n" if $@;
Does this reflect your experience and if so, is it worth notifying the module author? Thanks.

--Jim


In reply to MIME::Lite error handling by jlongino

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.