#!/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; } #### Use of uninitialized value in subroutine entry at blib\lib\Net\SSLeay.pm (autosplit into blib\lib\auto\Net\SSLeay\randomize.al) line 924.