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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.