2

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!

darkw1nd
  • 137
  • 1
  • 8

2 Answers2

1

I added this to my virtual host:

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

It worked!

darkw1nd
  • 137
  • 1
  • 8
  • 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 '19 at 20:28
0

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
GregL
  • 9,370
  • 2
  • 25
  • 36
drookie
  • 8,625
  • 1
  • 19
  • 29