I'm having a strange problem using MIME::Lite, quite some time ago I wrote or mostly stole a sendmail function. I've been using this in many different perl scripts for at least 15 years probably longer, never had a problem. Recently we built up a windows 2008R2 64bit server for passing data around SQL and the like.
This script here illustrates the issue, using komodo and strawberry perl. When I simply run the script it does all that I ask it to ie: I get my email, but I also get the error listed at the bottom. If however I break on the first eval in the function then run from there I get no error. Again, the script does run to completion either way.
Any ideas?
#!/usr/bin/perl -w
use strict;
use MIME::Lite;
use File::Basename;
sendmail('someuser@foobar.com', "Foo", "bar\n");
sub sendmail {
my ($recipients, $subject, $msg) = @_;
my ($me) = basename($0) =~ /^([^\.]*?)\./;
my $mailhost = 'mail.foobar.com';
my $fromAddress = $me . '@foobar.com';
$msg =~ s/[\r\n]//g;
my $type = ($msg =~ /\n/) ? 'text/plain' : 'text/html';
eval {
$msg=MIME::Lite->new(
To => "$recipients",
From => "$fromAddress",
Subject => "$subject",
Type => $type, #'text/html',
Data => "$msg"
) or warn "new $!";
};
do {
warn 'MIME::Lite->new() - ' . $@;
return 0;
} if $@;
eval {
MIME::Lite->send('smtp', "$mailhost") or warn $!;
$msg->send() or warn "sending $!";
};
do {
warn 'MIME:Lite->send() - ' . $@;
return 0;
} if $@;
1;
}
Error
Use of uninitialized value in subroutine entry at blib\lib\Net\SSLeay.pm (autosplit into blib\lib\auto\Net\SSLeay\randomize.al) line 924.