in reply to sendmail module problems

RTFL ;-)
Check your MTA (Sendmail, Postfix...) logs !
The answer is probably there waiting for you

Note: I can't test your code yet and assume the syntax error I can see is a typo...
and that your script doesn't die (wasn't so clear for me...)

"Only Bad Coders Code Badly In Perl" (OBC2BIP)