PHP mail function problem, free account

Hello everyone!
I really need some help with mail() function in PHP.
Namely, I have found multiple examples of this function call, but none seem to work.
I don’t know whether it is because of poorly written script or simply it’s something up to 000webhost. I have free account. Code outputs “Works”, but mail never arrives.
Thanks in advance!
Here is the code.
$to = ‘xxxxxxx@gmail.com’;
$subject = ‘subject’;
$message = ‘sometext’;
$headers = ‘From: xxxxx@whatever.com’ . “\r\n” .
‘Reply-To:xxxxx@whatever.com’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();

if (mail($to, $subject, $message, $headers))
{
    echo "works";
}
else
{
    echo "doesn't work";
}

Use SMTP :slight_smile:

This topic was automatically closed after 20 hours. New replies are no longer allowed.