# Simple email function

**URL:** <https://forum.kirupa.com/t/simple-email-function/234011>\
**Category:** programming\
**Created:** [July 29, 2007, 2:28pm UTC](https://forum.kirupa.com/t/simple-email-function/234011 "2007-07-29T14:28:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_S](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@J\_S](https://forum.kirupa.com/u/J_S)\
**Post date:** [July 29, 2007, 2:28pm UTC](https://forum.kirupa.com/t/simple-email-function/234011/1 "2007-07-29T14:28:10Z")

</div>

I’m having trouble trying to email from PHP on my server. I’ve written a simple php function which should email me, but I never get an email from it. Is there something wrong in my code, or could there be something wrong with my server setup? Here’s the function:

```auto
<?php
$eol = "
";
$name = "Joe Bloggs";
$email = "joe@joebloggs.com";

$headers = "From: $name <$email>".$eol;
$headers .= "Reply-To: $name <$email>".$eol;
$headers .= "Return-Path: $name <$email".$eol;

mail($email,"test subject","test message body",$headers);

echo "email should have been sent to $email";
?> 

```
