# Sending email via PHP fails

**URL:** <https://forum.kirupa.com/t/sending-email-via-php-fails/213752>\
**Category:** Uncategorized\
**Created:** [January 23, 2007, 12:24am UTC](https://forum.kirupa.com/t/sending-email-via-php-fails/213752 "2007-01-23T00:24:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Binji](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@Binji](https://forum.kirupa.com/u/Binji)\
**Post date:** [January 23, 2007, 12:24am UTC](https://forum.kirupa.com/t/sending-email-via-php-fails/213752/1 "2007-01-23T00:24:25Z")

</div>

I have an Apache 2.2.4 server with PHP 5.2 installed on it. PHP works since phpinfo() function displays the information about PHP, but when i ran this script:

```auto

<?php
$to = "myemail@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>");
 }
?>

```

it always returns “Message delivery failed…”. The email is real and exists.  
Now i dont know if its a server problem or a script problem. Im not really very good at either of them so i would like to ask for your expertise on this subject:)
