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.
1 |
su - CPANEL_USER |
If SSH access is not enabled, enable SSH in WHM.
Once logged in, verify sendmail works.
1 2 3 4 |
[sabtempco@buffalo ~]$ sendmail -f noreply@serverok.in admin@serverok.in 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
1 2 3 |
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
1 |
cagefsctl --force-update |