I have 2 domains on 000webhost. I have the exact same php file on each to do some testing. The file consists of the below:
<?PHP
$to = "example@gmail.com";
$subject = "Activate your Account";
$headers = "From: sample@gmail.com";
$body = "Email Sending Worked";
if(!mail($to, $subject, $body, $headers))
{
die("We couldn't sign you up this time. Please try again");
}
?>
Simple file that sends an email when run. I have masked the email address for this purpose. I run both files through the web browser URL. One of them sends the email but the other doesn’t. They both have the same code and both don’t take any parameters so don’t know why it doesn’t work.
The PHP mail() function can fail to work for a number of reasons. Some hosts disable it altogether; others may only allow a to (or from) email address that is registered with them. If you host has a support system I would ask them. If you can’t get anywhere with that or the error messages you get after following @John_Betong’s suggestion then using a mailer such as PHPMailer in place of the mail() function.