I want to disable PHP function mail via Apache2 virtual host configuration file. I want to do it for one virtual host, not for all virtual hosts, and I don't want disable this function in php.ini

How to do it correctly?

Thanks in advance!


I added this to my virtual host:

<Directory /dir/to/your/web/root>
        php_admin_value sendmail_path "tee mail.out > /dev/null"

It worked!

  • Did this work for you? I'm getting a apachectl configtest ... /main.conf error: Invalid command 'php_admin_value', perhaps misspelled or defined by a module not included in the server configuration – Brian Stinar May 22 at 20:28

You cannot disable php system calls on a per-virtualhost basis.

However you can:

  • Put this virtualhost into the container and disable sendmail there (method starts from disabling MTA to removing sendmail binary entirely)
    this is a method without any limitaions
  • Since PHP is an interpreter language you can find all mail( occurences with fgrep -R and comment out these lines.
    However, this doesn't work for pre-compiled solutions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.