PHP mail() works fine when I use this command
php -r "mail('pzuraq@gmail.com', 'Test Email', 'Test email body');"
However, when I try to run it via a webpage it doesn’t work. I’m using a global config file in /etc/msmtprc, though I’m thinking about trying to duplicate it and give ownership to apache because apparently msmtp is weird about config files and permissions (the current user has to own the file and the permissions have to be 600) but this shouldn’t apply with the global config.
When I run the mail() function on the webpage, it returns false and doesn’t print any error to the log.
The point is that you have different
php.inifiles for cli & apache php executable.So your cli php.ini version is configured as it’s supposed to, but your apache php.ini (or, rather, your web server’s
php.iniis probably not configured properly.In other words, command-line php and web php use different configuration.