I cannt send mail from php script although I'm able to send it from command line with sendmail and

php sendMyMail.php

I've already attempted these

  1. httpd is running as apache user and that i added apache user to smmsp group

  2. httpd_can_sendmail --> on

  3. SELinux status:                 enabled
    SELinuxfs mount:                /selinux
    Current mode:                   permissive
    Mode from config file:          enforcing
    Policy version:                 24
    Policy from config file:        targeted
    

However in httpd error_log still showing this error

sh: /usr/sbin/sendmail: Permission refused

Can anybody have idea? I actually do really appreciate all of your suggestions and extremely exhausted with that one.

That you could send emails in the command line does not necessarily mean that any user can (apache for example).

Make sure that apache can really send emails:

sudo -u apache sendmail root@localhost

Browse the mail logfile (usually /var/log/mail.log) to determine what went down. Mailbox of root is generally in /var/spool/mail/root ). Tipp: Use other user not the same as root if you won't want to use root like a guinea pig.