jazzman1 Posted April 5, 2013 Share Posted April 5, 2013 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 = '[email protected]'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\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 [email protected] // to my local mail server date | sendmail -v [email protected] Results: <[email protected]>: 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; [email protected]Arrival-Date: Fri, 5 Apr 2013 12:05:50 -0400 (EDT)Final-Recipient: rfc822; [email protected]Action: 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: <[email protected]>Received: by centos-box.localdomain (Postfix, from userid 500) id 90D63100B04; Fri, 5 Apr 2013 12:05:50 -0400 (EDT)Message-Id: <[email protected]>Date: Fri, 5 Apr 2013 12:05:50 -0400 (EDT)From: [email protected] (jazzman)To: undisclosed-recipients:; For some reason the mail function does not work to me!Thanks,jazz.... Link to comment https://forums.phpfreaks.com/topic/276578-mail-php-does-not-work/ 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? Link to comment https://forums.phpfreaks.com/topic/276578-mail-php-does-not-work/#findComment-1423101 Share on other sites More sharing options...
jazzman1 Posted April 5, 2013 Author Share Posted April 5, 2013 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 Link to comment https://forums.phpfreaks.com/topic/276578-mail-php-does-not-work/#findComment-1423105 Share on other sites More sharing options...
jazzman1 Posted April 5, 2013 Author Share Posted April 5, 2013 Yep, I disabled SELinux and now everything is just fine Solved. Link to comment https://forums.phpfreaks.com/topic/276578-mail-php-does-not-work/#findComment-1423124 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.. Link to comment https://forums.phpfreaks.com/topic/276578-mail-php-does-not-work/#findComment-1423180 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.