PHP mails not working on Cpanel Server

On a cpanel server, PHP scripts can’t sent email. Incoming and outgoing emails for email users (mailbox) are working properly.

To debug, loggged in to SSH as one of the cpanel user.

If SSH access is not enabled, enable SSH in WHM.

Once logged in, verify sendmail works.

I get above error message. This is because permission error with /usr/sbin/sendmail.

To fix, run

If you are using CloudLinux CageFS, try disable and see if it works. If it work after you disable CafeFS, run