Php – Ubuntu Jaunty + sendmail + PHP + mail() Premission Errors

apache-2.2permissionsPHPsendmail

I'm having issues trying to get PHP's mail function to work on my Ubuntu 9.04 VPS with sendmail and Apache (and other less relevant stuff, of course).

From PHP I receive no error, save a return value of false from the mail function.

The last error in /var/log/mail.err is

sendmail[14837]: NOQUEUE: SYSERR(www-data): can not chdir(/var/spool/mqueue-client/): Permission denied

Now, I appreciate that this is saying www-data (the user Apache is running as) does not have read access on some required directory (/var/spool/mqueue-client).

So, knowing that (and for test purposes only), I ran chmod 777 /var/spool/mqueue-client and reran the script, which this time succeeded (hurray), however /var/log/mail.err now says

sendmail[14874]: dangerous permissions=42777 on queue directory /var/spool/mqueue-client/

So I'm wondering how I can configure things so my script can run using non-dangerous permissions.

Best Answer

You could try to chmod 775 the /var/spool/mqueue-client and then add www-data to the smmsp group. I agree though if you can switch to postfix somehow, you would be much better off.