NOQUEUE: SYSERR(apache): can not chdir(/var/spool/clientmqueue/): Permission denied

I still use Apache for my test bed/sandbox when working on a few of my own personal applications. Recently I had setup a brand new sandbox for some work on an application I was working on. Following my own guide it wasn’t no more than a few minutes.

Mid swing, I was wondering why my php scripts weren’t sending mails. A quick look at the log

tail -f /var/log/maillog  
#Jan 29 14:52:21 s01 sendmail[1920]: NOQUEUE: SYSERR(apache): can not chdir(/var/spool/clientmqueue/): Permission denied
#Jan 29 21:04:19 s01 sendmail[2777]: NOQUEUE: SYSERR(apache): can not chdir(/var/spool/clientmqueue/): Permission denied

# Taking  alook at the Selinux Booleans, httpd is not allowed to use sendmail
getsebool -a | grep mail  
#allow_postfix_local_write_mail_spool --> on
#httpd_can_sendmail --> off

setsebool -P httpd_can_sendmail on  

I’ve had this little script tucked away on my dev servers for a while. It’s been great for testing preventing you from going mad. Kudos to the source.

<?php  
error_reporting(E_ALL ^ E_NOTICE);  
?>
<html>  
<head><title>PHP Mail() test</title></head>  
<body>  
This form will attempt to send a test email. Please enter where this test should be sent to<br><p>  
<form action = "sendmail.php" method = "post" name="sendmail">  
Enter an email address: <input type = "text" name = "to"><br>  
<input type="submit" value="Send" name="submit"><input type="reset" value="Reset" name="reset"><br><p>  
<?php  
if(isset($_POST['to'])) {  
    $host = $_SERVER['HTTP_HOST'];
    $uri = $_SERVER['SCRIPT_URI'];
    $mail_to=$_POST['to'];
    $mail_subject="Test email from $host";
    $mail_body="This is a test email, sent from $uri";
    $header = "Content-type: text/html\n";
    $header .= "From: \"PHP mail() Test Script\"<[email protected]$host>\n";
    if(mail($mail_to, $mail_subject, $mail_body,$header)) {
        print "Email sent successfully!";
    } else {
        print "Email did not send";
    }
}
?>
</body>  
</html>  

Now we’re back to work.

comments powered by Disqus