I have an issue with outgoing email via Wordpres (not only wordpress) on a website when both PHP-FPM and chroot are enabled.
The email is not delivered to the MTA, I have no entry in the mail.log… Just nothing happens!
The setup PHP-FPM without chroot works fine.
The setup FCGId with chroot works fine too…
There is a way to send mail in the chrooted enviroment with PHP-FPM?
How are you trying to send mail? FPM and chroot are mostly irrelevant, though how you run PHP may determine which PHP modules you have available.
Since you’re sending from a web app and since you see nothing in the mail log, you need to look at the error log, mostly likely, but the application may also have a log.
The webapp is a simple wordpress website installed via Virtualmin script installer.
Also there is no error in the error log.
I used “WP mail SMTP” plugin to try to debug and I receive this log:
Versions:
WordPress: 6.0.3
WordPress MS: No
PHP: 8.0.24
WP Mail SMTP: 3.6.1
Params:
Mailer: mail
Constants: No
Server:
PHP.mail(): Yes
PHPMailer Debug:
Could not instantiate mail function.
Debug:
Email Source: WP Mail SMTP
Mailer: Default (none)
PHPMailer was able to connect to SMTP server but failed while trying to send an email.
If I change the PHP execution mode to FCGid or remove the chroot, everything works as expected…
The chroot is not relevant. Apache and FPM do not run chrooted, even if the user shell does.
And, I don’t think this indicate mail is disabled, I think it indicates a misconfiguration. This error:
PHPMailer was able to connect to SMTP server but failed while trying to send an email.
Does not indicate anything is missing.
If the app is actually communicating with the local SMTP server, however, there should be something in the mail log. Which we’d need to see. Unless the app is configured to send somewhere else entirely, in which case, that needs to be corrected.
The app is vanilla WP installed via the virtualmin script installer.
The php-fpm .ini is almost default, I olny changed the memory, upload and timeout limits…
The server is freshly installed and this is the first vhost I activated.
There is no entry related to the transaction in the mail log…
I also tried a simple script to check the php mail() function (How to test and fix the php mail() function) and it return “Error: Message not accepted” but nothing in the mail log.
If I remove the chroot, the script works, I receive the the email and i can find the transaction in the mail.log
I also noticed that others 2 older servers (with debian 9 and latest virtualmin) that I manage, have the same issue.
Nope, as I told before, if I remove chroot OR change the php execution to FCGid, the email works fine.
I also receive the emails sent by Virtulamin on server creation…
It is the default behaviour of Wordpress… It uses php-mail() to send emails. @Joe says that FPM do not run chrooted, but there is this line in php-fpm.ini
chroot = /home/chrooot/123454678900
Perhaps it means that it runs chrooted?
I know I can use some wp plugin to setup a different SMTP, but should be better to have something that works out of the box…
There is some setting in php-fpm.ini that can fix this?