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.
su - CPANEL_USER
If SSH access is not enabled, enable SSH in WHM.
Once logged in, verify sendmail works.
[sabtempco@buffalo ~]$ sendmail -f [email protected] [email protected] sendmail: Not running with correct effective GID. Is sendmail binary setgid mailtrap? sendmail: Not running with correct effective GID. Is sendmail binary setgid mailtrap? [sabtempco@buffalo ~]$
I get above error message. This is because permission error with /usr/sbin/sendmail.
To fix, run
chmod +x /usr/sbin/sendmail chmod g+s /usr/sbin/sendmail chown root:mailtrap /usr/sbin/sendmail
If you are using CloudLinux CageFS, try disable and see if it works. If it work after you disable CafeFS, run
cagefsctl --force-update