Looking at mail documentation it seems that it prints warnings when certain situations happen:
Could we perhaps install a special error handler around mail() calls that would catch these and log them to the error log?Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.