So you dont want to install the Sendmail daemon in every Chroot environment to be able to use the PHP mail() function? Of course not.. the simple solution is called mini_sendmail, it connects to localhost on port 25 to deliver the emails.
First of, download and compile the sourcecode:
# wget http://wiki.mattrude.com/images/5/52/Mini_sendmail-1.3.6.tar.gz
# tar zxvf Mini_sendmail-1.3.6.tar.gz
# cd mini_sendmail-1.3.6
Now you’ve got your new binary, lets try it out:
# echo -e "'Subject: test'\nTesting.." | ./mini_sendmail -email@example.com' -v firstname.lastname@example.org
If you are using the PHP7-FPM on Debian Stretch then edit the following file:
# vim /etc/php/7.0/fpm/pool.d/site.com.conf
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -email@example.com'
Now you should be able to use the PHP mail() function from your Chroot
2018-07 Workaround for
"./mini_sendmail: can't determine username"
then you have to make the following changes to mini_sendmail.c
/* username = getlogin(); */ username = "xn--1ca.se";
and then recompile with:
# gcc mini_sendmail.c