sendmail doesn't work for root

I've created a Perl daemon that needs to send an email when an error/shutdown occurs. I use the Perl Email::Valid module and that uses sendmail. When I run the script as a regular user, the email is sent with no issues. When I run the script as the root user, I get the following message in /var/log/maillog;

Jul 27 08:36:20 server_name sendmail[4933]: NOQUEUE: SYSERR(root): /etc/mail/submit.cf: line 544: fileclass: cannot open '/etc/mail/trusted-users': World writable directory

The daemon will run as root so I have to address this. Has anyone had any experience with this issue? I've searched everything I can think of and found no solution. Any help would be greatly appreciated.

It's telling you the problem -- /etc/mail/trusted-users or /etc/mail is world-writable. Someone must have used the magic sledgehammer, chmod 777-ing it in the past in a misguided attempt to fix a 'problem'.

When something is running as root, loose permissions are a big deal. Anything could inject malicious contents into there and mislead a root daemon, possibly executing arbitrary commands or escalating permissions. So it does checks on it that it wouldn't when running as a limited user.

Reduce the permissions to what you actually need.