On CloudLinux server running sites under CafeFS, one of the customer can’t send email. I created a test PHP script, run on client site.
# cat mail.php <?php mail("[email protected]"," Online booking", "this is onlinebooking email");
No mail is send out.
Nothing in exim mail server log (/var/log/exim_mainlog).
I disabled CageFS, mail started working properly. Re enabled CageFS, it failed to work.
I enabled SSH for this customer, then login to SSH, run the mail.php from SSH prompt, got following error
uzbekistanconsul@server20 [~/public_html]# php mail.php /bin/cat: /var/.cagefs/.cagefs.token: Permission denied You are not authorized to run this command uzbekistanconsul@server20 [~/public_html]#
NOTE: never run as user root, i know this warning is silly 🙂
This error shows up only if mail() is last line in the mail.php, for example, if you have an
echo "mail send";
Line after mail(), that does not shows up. I found out that by accident or i because i am lucky!
To fix this problem, you need to find the .csgefs.token for this site. So as user too, run
root@server20 [~]# find /var/cagefs -name "uzbekistanconsul" /var/cagefs/46/uzbekistanconsul /var/cagefs/46/uzbekistanconsul/home/uzbekistanconsul /var/cagefs/46/uzbekistanconsul/var/cpanel/userdata/uzbekistanconsul root@server20 [~]#
We found the cagefs skelton directory for the site is
I went to the .cafefs folder and checked file, it had a wrong owner.
root@server20 [/var/cagefs/46/uzbekistanconsul/.cagefs]# ls -la total 12 drwxr-xr-x 2 root nobody 4096 Oct 27 05:33 ./ drwxr-x--x 6 root root 4096 Oct 27 05:33 ../ -r-------- 1 1646 nobody 16 Oct 27 05:33 .cagefs.token root@server20 [/var/cagefs/46/uzbekistanconsul/.cagefs]#
Fixed it by running
chown uzbekistanconsul:nobody /var/cagefs/46/uzbekistanconsul/.cagefs/.cagefs.token