Don't you get any more detailed error message than "mail not
working"? (look in the syslog, MTA logfiles, etc.)
Anyhow, something like this works fine for me (my incarnation of
sendmail needs the -t option to read the addressees from the
message headers...):
#!/usr/bin/perl
open MAIL, "| /usr/sbin/sendmail -t" or die "$!";
print MAIL << 'EOF';
To: joe@here.com
From: smith@here.com
Subject: data subject
message body here
EOF
close MAIL or die "$!";
|