I'm running a multi-site setup with nginx and php-fpm 7.4 on Ubuntu 16.04. All sites are chrooted and everything runs like a charm. Except mail() over sendmail. (php-fpm version should not matter here, I'm struggling with this since 7.1).
Sendmail and postfix are running and configured. This line sends an email.
echo "Subject: sendmail test" | /sbin/sendmail -t -i root@example.com
Trying "the same" via PHP does not work:
mail("foobar@gmail.com","Testing","It's a test.", "root@example.com");
Does not work. mail() returns false. The mail log (/var/log/mail.log) remains empty. I configured log for sendmail with
php_value[mail.log] = /logs/mail.log
This log shows the call, e.g.
[16-Oct-2020 21:17:46 Europe/Berlin] mail() on [/htdocs/mail.php:8]: To: foobar@gmail.com -- Headers: root@example.com -- Subject: Testing
I also installed mini_sendmail (https://acme.com/software/mini_sendmail/), latest version, because I realised that sendmail requires a dozen files that I had to mount into my chrooted folders. So I downloaded mini_sendmail, renamed it to sendmail and put it into the chrooted folder /var/nginx/example_com/usr/sbin/sendmail
Running thes script from the command line with php, php-cgi also works:
php-cgi mail.php
php-cgi mail.php
phpinfo() also shows, that everything is configured (sendmail-path). shell-exec and exec are allowed functions. /bin/sh is also within the chroot-jail. Everything seems to be okay.
Any ideas, what I'm missing here? I don't even get an error message, that could help me.