Some advice:
-go to http://theoryx5.uwinnipeg.ca/CPAN/data/Mail-Sendmail/Sendmail.html
and copy and paste the example code into your script. Modify the easy to follow example as needed.
-use $Mail::Sendmail::error
Comment on Re: Passing variable to an email message.
use Mail::Sendmail;
%mail = ( To => 'you@there.com',
From => 'me@here.com',
Message => "This is a very short message"
);
sendmail(%mail) or die $Mail::Sendmail::error;
print "OK. Log says:\n", $Mail::Sendmail::log;