He said PHP mail() - i.e. SMTP on localhost to port 25 - does send email, so his mailserver is not configured to disallow mail sent locally via SMTP.
His problem is trying to use SMTP on smtp.example.com to port 587 with authentication which could be failing for a dozen reasons.