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