# Email() wont work?

**URL:** https://forum.kirupa.com/t/email-wont-work/262458
**Category:** Uncategorized
**Created:** [June 6, 2008, 2:30am UTC](https://forum.kirupa.com/t/email-wont-work/262458 "2008-06-06T02:30:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jeffonfire](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@jeffonfire](https://forum.kirupa.com/u/jeffonfire)
#### Post date: [June 6, 2008, 2:30am UTC](https://forum.kirupa.com/t/email-wont-work/262458/1 "2008-06-06T02:30:48Z")

</div>

```php
<?php
$to = "electrifiedpete@gmail.com";
$subject = "Hi!";
$body = "Hi,

How are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }
?>

```

I run it but the Email never arrives and it is not in the spam box either???

---

<div class="post-metadata">

### Author: ![djheru](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/djheru/32/3190_2.png) [@djheru](https://forum.kirupa.com/u/djheru)
#### Post date: [June 6, 2008, 3:47am UTC](https://forum.kirupa.com/t/email-wont-work/262458/2 "2008-06-06T03:47:23Z")

</div>

It is probably being blocked by the server because you haven’t included any headers. The receiving mail server likely thinks that the message is blatant spam, and won’t let it thru.

I had good success looking at the comments in the [php.net](http://php.net) page for mail() to get some more robust functionality

---

<div class="post-metadata">

### Author: ![jeffonfire](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@jeffonfire](https://forum.kirupa.com/u/jeffonfire)
#### Post date: [June 6, 2008, 3:52pm UTC](https://forum.kirupa.com/t/email-wont-work/262458/3 "2008-06-06T15:52:18Z")

</div>

OK thanks!

---

<div class="post-metadata">

### Author: ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)
#### Post date: [June 6, 2008, 4:10pm UTC](https://forum.kirupa.com/t/email-wont-work/262458/4 "2008-06-06T16:10:30Z")

</div>

Switch to PEAR mail. Overall just better 😃

---

<div class="post-metadata">

### Author: ![djheru](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/djheru/32/3190_2.png) [@djheru](https://forum.kirupa.com/u/djheru)
#### Post date: [June 6, 2008, 6:14pm UTC](https://forum.kirupa.com/t/email-wont-work/262458/5 "2008-06-06T18:14:14Z")

</div>

Unless you need to develop in an environment where it is not installed.
