Do you see any errors, either from sending the test mail or in the log files?
Usually the php mail function does send to yourself but not to others. That's because the domain has not properly set up spf records. Can you explain exactly what the difference is between your php file and the Flarum settings? Did you use the correct "from" (called Adresses in the Mail page of flarum).