PHP mail() not working with Postfix on ubuntu 16.04

Solution 1:

Thank you @bgtvfr those were all working when I tested it. Sending mail from the command line was working just fine as intended.

The errors I listed from my mail.log were caused by my php.ini file not being configured correctly.

At one point I set sendmail_path = /usr/sbin/posfix and then while I had changed it back to the above code, pointing to sendmail I had not reloaded the php.ini settings. I'm running ubuntu with nginx and php7.0, however restarting nginx will not reload your php settings, so I had to run the following:

sudo /etc/php7.0/fpm/php.ini restart

Once this was reset to sendmail_path = /usr/sbin/sendmail then it started working as intended.