# Php mail() failing?

**URL:** https://forum.kirupa.com/t/php-mail-failing/196593
**Category:** Uncategorized
**Created:** [August 9, 2006, 5:09pm UTC](https://forum.kirupa.com/t/php-mail-failing/196593 "2006-08-09T17:09:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Sifodyas](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@Sifodyas](https://forum.kirupa.com/u/Sifodyas)
#### Post date: [August 9, 2006, 5:09pm UTC](https://forum.kirupa.com/t/php-mail-failing/196593/1 "2006-08-09T17:09:57Z")

</div>

I was implementing the tutorial-based code and was having no end of difficulty working out why I was not receiving the emails.

So, one thing I tried was to directly call up the **email.php** file by typing in the full path and it seems that if I do a _if (mail(…))_ check that it returns a **false** result suggesting that the _mail_ command failed.

```php
<?php

$email = "noone@nowhere.com";
$name = "no one";
$sentTo = " **mygmailaccount**";
$subject = "test subject";
$headers = "From: " . $name . "<" . $email . ">
";
$headers .= "Reply-To: " . $email . "
";
$headers .= "Return-Path: " . $email;
$message = "this is a test";

if (mail($sendTo, $subject, $message, $headers))
{
    echo "Message was sent.";
}
else
{
    echo "Message was not sent?!";
}
?>

```

Each time I call the \*email.php \*directly, I get the _Message was not sent_ response.

I’ve setup a **phpinfo** file [here](http://www.birkvideo.com/proof/test.php), but I’m not sure how to validate any of this.

Different email accounts (which are operating fine) were tried.

I’ve already gone through the forum archives and can not see a solution, so I really could do with some help on this one.

Any help would be greatly appreciated.

Cheers.
