Just at first glance, you have
'$_' when you mean
"$_" - note the double quotes instead of the single ones. Single quotes mean "as is", while double quotes man "interpolate variables".
Another thing I see, which may or may not be a problem, is that by the time you get to the sendmail() command, you only have the last line of bas.txt. Perhaps you want to replace the while loop with something like:
$txt = <RES>;
print $txt;
-- Dan