mail function not working

sreeninair

Well-Known Member
Dec 23, 2013
100
0
16
cPanel Access Level
Root Administrator
Hello,

I am unable to send using mail() function. Please see the details.

========

Test mail php file.


]# cat testmail.php
<?
if (mail('[email protected]', 'PHP test', 'This is a test of mail().')) {
echo "Mail successful";
} else {
echo "Mail failed.";
};
?>

Browser output :Mail failed.


==========

Apache Error log:

sh: /usr/local/bin/sendmail-logger: No such file or directory

# ll /usr/local/bin/sendmail-logger
-rwxr-xr-x 1 root root 169 Jun 25 2013 /usr/local/bin/sendmail-logger*

# which sendmail
/usr/sbin/sendmail

#grep sendmail /usr/local/lib/php.ini
;sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = "/usr/sbin/sendmail -t -i"
sendmail_path=/usr/sbin/sendmail -t ;
;sendmail_path = /usr/local/bin/sendmail-logger

===============


Kindly assist.

Thanks
Sreeni
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello :)

Do you notice any error messages in the error_log within the script's directory, or in the Apache error log (/usr/local/apache/logs/error_log)? Which PHP handler are you using? Is "Prevent “nobody” from sending mail" enabled under the "Mail" tab in "Tweak Settings" within WHM?

Thank you.
 

sreeninair

Well-Known Member
Dec 23, 2013
100
0
16
cPanel Access Level
Root Administrator
Hello Michael,

The Prevent “nobody” from sending mail" enabled under the "Mail" was enabled. The error message in apache log was 'sh: /usr/local/bin/sendmail-logger: No such file or directory'. I have fixed it by running upcp --force after removing exim from /etc/yum.conf (exclude) . Thanks for your help.

Thanks
Sreeni