Environment: Debian 7; PHP 5.4.39; Apache 2.2; ISPConfig
Using the Perfect Server Debian guide from howtoforge, I built a web server to serve some PHP applications. My intention is to use an external SMTP server with the php mail()
function. I have uninstalled postfix, installed MSMTP updated the sendmail_path
in my php.ini file.
I have also confirmed the MSMTP
settings work. After updating my php.ini file and restarting the server, phpinfo()
still shows the old sendmail_path /usr/sbin/sendmail -t -i -fwebmaster@$domain.com
instead of my custom MSMTP path "/usr/bin/msmtp -C /etc/msmtprc --logfile /var/log/msmtp.log -a $domain -t"
From phpinfo()
, the loaded configuration file is /etc/php5/cgi/php.ini
. However, when I run php -i | grep Configuration
at shell, I get Loaded Configuration File => /etc/php5/cli/php.ini
(notice the difference in paths?).
Notwithstanding, I proceeded to update the paths for both files, including all others found. They are about 4 different versions at these locations:
- /etc/php5/apache2/php.ini
- /etc/php5/cgi/php.ini
- /etc/php5/cli/php.ini
- /etc/php5/fpm/php.ini
ISPConfig lets you choose to run hosted websites under different PHP configurations so I assumed these multiple files were for different configurations. However, even after updating all files and restarting the server, phpinfo()
still displays the old sendmail_path
.
Further Diagnosis:
I have uploaded a simple php script that uses the mail()
function to dispatch an e-mail to my address. When the script is called from the browser, it fails with the error contained, however running it at shell php /path/to/script/mail.php
successfully sends the e-mail and I receive it.
My questions:
- How can I PHP scripts on this server to relay mail using MSMTP?
- How can I get
phpinfo()
to display the correct path? - Why am I able to execute the
mail.php
script at shell and not through the browser, even thoughwww-data
(the web server user) has access rights?