I have an Ubuntu 16.04 server with ISPConfig Version: 3.1dev. and many websites installed (I know I have to update my system). I also set up Postfix with an SMTP relay service (Mailgun). For some reason, the PHP Mail function stopped working, and now the WordPess sites can't send emails. The only way to send emails is using SMTP. When I try to send a test email with a special plugin, it shows the following error message: Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Just a guess, did you maybe use chrooted PHP in that site? If yes, then you must use PHP as postfix and its sendmail wrapper that is used by PHP mail() function are located outside of the jail.
How can I check that? The problem is in every site actually, even the new ones that I create, but it used to work fine.
I just figured out that it works after I changed the PHP mode from Fast-CGI to CGI. However, after I made that change the websites linked to subdomains won't work anymore.
I tried but still the emails won't be sent. It only works when I change it to PHP mode CGI. However, I can't change the PHP version, and besides I would like to know why the websites linked to subdomains won't work with that mode.
You could create a simple phpinfo() file and request it in both CGI and FAST-CGI mode to see which php.ini file is in use for each mode, then compare them.