PHP Mail() / Exim - Failed to create spool file /var/spool/exim/input//...
#1
Hi everyone,

I've installed a WordPress blog site on my VPS and while setting it up, I've remember before on my old VPS that after running WordPress installation script, I've received an email notification, but this time, I don't. So I tried to test and verify by commenting on some post/page on my blog, but still failed to received an email notification. Then I investigate regarding the problem, the following are the details, logs that I've found based on my investigation and search on Google for something related to my problem:

I've switch from PostFix to Exim, it is working fine as I'm receiving cron system mails and was able to send and receive a test mail by executing the following command:

Terminal

$ echo "Thisis a test." | mail -s Test me@gmail.com


I've confirmed that the mail is failing to be sent when it is sent by PHP Mail() function by testing the following codes:
Code:
<?php
        $to      = 'me@gmail.com';
        $subject = 'Test Message';
        $message = 'Testing PHP mail function.';
        $headers = 'From: test@kvps15c.mydomain.com' . "\r\n" .
                   'X-Mailer: PHP/' . phpversion();

        mail($to, $subject, $message, $headers);
?>

The following are the lines from /var/log/exim/main.log that contains the error:
[nopoints]
Code:
2012-03-09 17:14:28 1S5vu8-0000XK-V1 Failed to create spool file /var/spool/exim/input//1S5vu8-0000XK-V1-D: Permission denied
2012-03-09 17:15:56 1S5vvY-0000XR-8V Failed to create spool file /var/spool/exim/input//1S5vvY-0000XR-8V-D: Permission denied
[/nopoints]
And these are from /var/log/maillog:
[nopoints]
Code:
Mar  9 17:14:28 kvps15c exim[2066]: 2012-03-09 17:14:28 1S5vu8-0000XK-V1 Failed to create spool file /var/spool/exim/input//1S5vu8-0000XK-V1-D: Permission denied
Mar  9 17:14:28 kvps15c exim[2066]: 2012-03-09 17:14:28 1S5vu8-0000XK-V1 Failed to create spool file /var/spool/exim/input//1S5vu8-0000XK-V1-D: Permission denied
Mar  9 17:14:28 kvps15c exim[2066]: exim: could not open panic log - aborting: see message(s) above
Mar  9 17:15:56 kvps15c exim[2073]: 2012-03-09 17:15:56 1S5vvY-0000XR-8V Failed to create spool file /var/spool/exim/input//1S5vvY-0000XR-8V-D: Permission denied
Mar  9 17:15:56 kvps15c exim[2073]: 2012-03-09 17:15:56 1S5vvY-0000XR-8V Failed to create spool file /var/spool/exim/input//1S5vvY-0000XR-8V-D: Permission denied
Mar  9 17:15:56 kvps15c exim[2073]: exim: could not open panic log - aborting: see message(s) above
[/nopoints]

I found out from searching from Google that I should check the file/folder permission of the following:
[nopoints]

Terminal

$ ls -l /var/spool/exim/
total 12
drwxr-x---. 2 exim exim 4096 May 25 2011 db
drwxr-x---. 2 exim exim 4096 Mar 9 17:17 input
drwxr-x---. 2 exim exim 4096 Mar 9 17:17 msglog

[/nopoints]
The above seems to be fine, but some said it should be root:mail, but also failed when I've tried. Some also said that it should be mailnull:mail, but there's no mailnull user/group on CentOS.

There's also information that exim should be sticky root, which I think the following confirm its okay:

Terminal

$ ls -l /usr/sbin/exim
-rwsr-xr-x. 1 root root 1075788 May 25 2011 /usr/sbin/exim


I've reach the dead end here and I've been Googling for a couple of days with no working solution found, so I hope someone could help me solve this. TIA.
Thanks FreeVPS.us! for the free VPS and for all the knowledge that I've learned here at the forum.
#2
Try chmoding it to 777 and see if it works.
#3
Okay, I have...

Terminal

# chmod -R 777 /var/spool/exim

but unfortunately, still it did not work.
Thanks FreeVPS.us! for the free VPS and for all the knowledge that I've learned here at the forum.
#4
For debugging, try
chmod -R 777 /var/spool/
#5
use sudo when chmod-in ... possibly you need root right for doing so on that folder

Zeboo/Greg
#6
Try "chmod 4755 /usr/sbin/exim" (setuid)
Also are you sure /var/spool/exim should belong to exim and not mail? (I'm not sure on CentOS)
#7
@f8ll it's owned by exim on my VPSs.

Terminal

ls -lsa /var/spool/exim
total 24
4 drwxr-x--- 6 exim exim 4096 Feb 6 11:21 .
4 drwxr-xr-x 9 root root 4096 Dec 28 13:10 ..
4 drwxr-x--- 2 exim exim 4096 Nov 11 14:29 db
4 drwxr-x--- 2 exim exim 4096 Mar 9 16:26 input
4 drwxr-x--- 2 exim exim 4096 Mar 9 16:26 msglog
4 drwxr-x--- 2 exim exim 4096 Mar 9 16:26 scan

#8
@Zeboo
I'm already root when I chmod and I double check with ls -l on the directories/files to verify the permissions.

@f8ll
I think its already setuid:

Terminal

# ls -l /usr/sbin/exim
-rwsr-xr-x. 1 root root 1075788 May 25 2011 /usr/sbin/exim

is that the "s" instead of "x" on the user execute permission?

Its really confusing when I search this on Google, they are saying different combination of user:group ownership that should be set to /var/spool/exim, but most that I found are for Debian. Eventhough I've tried almost all of them, but nothing works, until I mess up the file/directory permission of /var/spool/exim and end up reinstalling Exim.

This couldn't be a problem with PHP right? because as far as I understand PHP just call/execute mail/sendmail which wraps to Exim?
Thanks FreeVPS.us! for the free VPS and for all the knowledge that I've learned here at the forum.
#9
Under which user is Exim running? Do this to find out:
# ps -ef |grep exim

After you know the {user} under which Exim is running, do this:

# chown -R user:user /var/spool/exim
# chmod -R a+rwx /var/spool/exim
#10
Exim is run by exim:

Terminal

$ ps -ef | grep exim
exim 1627 1 0 Mar09 ? 00:00:00 /usr/sbin/exim -bd -q1h

The directory /var/spool/exim and its sub-directories are already owned by exim with read, write and execute permission:

Terminal

ls -la /var/spool/exim
total 20
drwxr-x---. 5 exim exim 4096 May 25 2011 .
drwxr-xr-x. 9 root root 4096 Mar 2 23:47 ..
drwxr-x---. 2 exim exim 4096 May 25 2011 db
drwxr-x---. 2 exim exim 4096 Mar 10 14:44 input
drwxr-x---. 2 exim exim 4096 Mar 10 14:44 msglog

Thanks FreeVPS.us! for the free VPS and for all the knowledge that I've learned here at the forum.




Users browsing this thread: 1 Guest(s)