jazzman1 Posted April 5, 2013 Share Posted April 5, 2013 (edited) Hey folks, yesterday I decided to upgrade my CentOS machine from 6.3 to 6.4 and now my php mail function stoped to work.What I've tested so far:1. If I try to send a message to my remote mail server I've got a false result. <?php phpinfo(); if ( function_exists( 'mail' ) ) { echo 'mail() is available' . '<br />'; } else { echo 'mail() has been disabled'.'<br />'; } $to = 'myEmail@gmail.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: jazzman@centos-box.localdomain' . "\r\n" . 'Reply-To: jazzman@centos-box.localdomain' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if(mail($to, $subject, $message, $headers)) { echo "mail send ... OK"; } else { echo "mail send ... ERROR!"; } Results: mail() is availablemail send ... ERROR! 2. I checked the path to the default mail client - sendmail and it is correct: sendmail_path: /usr/sbin/sendmail -t -i 3. Then I try to send a message to my remote server through a BASH script and the sendmail works fine: // to my remote mail server date | sendmail -v myEmail@gmail.com // to my local mail server date | sendmail -v jazzman@centos-box.localdomain Results: <jazzman@centos-box.localdomain>: delivery via local: delivered to mailbox--90D63100B04.1365177950/centos-box.localdomainContent-Description: Delivery reportContent-Type: message/delivery-statusReporting-MTA: dns; centos-box.localdomainX-Postfix-Queue-ID: 90D63100B04X-Postfix-Sender: rfc822; jazzman@centos-box.localdomainArrival-Date: Fri, 5 Apr 2013 12:05:50 -0400 (EDT)Final-Recipient: rfc822; jazzman@centos-box.localdomainAction: deliveredStatus: 2.0.0Diagnostic-Code: X-Postfix; delivery via local: delivered to mailbox--90D63100B04.1365177950/centos-box.localdomainContent-Description: Message HeadersContent-Type: text/rfc822-headersReturn-Path: <jazzman@centos-box.localdomain>Received: by centos-box.localdomain (Postfix, from userid 500) id 90D63100B04; Fri, 5 Apr 2013 12:05:50 -0400 (EDT)Message-Id: <20130405160550.90D63100B04@centos-box.localdomain>Date: Fri, 5 Apr 2013 12:05:50 -0400 (EDT)From: jazzman@centos-box.localdomain (jazzman)To: undisclosed-recipients:; For some reason the mail function does not work to me!Thanks,jazz.... Edited April 5, 2013 by jazzman1 Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted April 5, 2013 Share Posted April 5, 2013 are there any php detected warnings or notices? Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted April 5, 2013 Author Share Posted April 5, 2013 (edited) No, the error_reporting shows nothing. I think that it's a server security issue and coming from selinux in centos. Let me check in the error's log in the server, something happened here. Apr 5 12:07:21 centos-box postfix/sendmail[4899]: fatal: chdir /var/spool/postfix: Permission denied Edited April 5, 2013 by jazzman1 Quote Link to comment Share on other sites More sharing options...
Solution jazzman1 Posted April 5, 2013 Author Solution Share Posted April 5, 2013 Yep, I disabled SELinux and now everything is just fine Solved. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted April 5, 2013 Author Share Posted April 5, 2013 I found a solution without disabling SELinux. Here is it: [root@centos-box jazzman]# /usr/sbin/getsebool httpd_can_sendmail httpd_can_sendmail --> off [root@centos-box jazzman]# setsebool -P httpd_can_sendmail 1 [root@centos-box jazzman]# /usr/sbin/getsebool httpd_can_sendmail httpd_can_sendmail --> on Hope this helps someone! jazz.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.