# Super simple script rewrite

**URL:** <https://forum.kirupa.com/t/super-simple-script-rewrite/186282>\
**Category:** Uncategorized\
**Created:** [April 20, 2006, 9:20am UTC](https://forum.kirupa.com/t/super-simple-script-rewrite/186282 "2006-04-20T09:20:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebjo](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@sebjo](https://forum.kirupa.com/u/sebjo)\
**Post date:** [April 20, 2006, 9:20am UTC](https://forum.kirupa.com/t/super-simple-script-rewrite/186282/1 "2006-04-20T09:20:00Z")

</div>

Can someone please correct this simple php script I am using for my mailform.  
It has worked fine on my previous server. On my new server I am still getting the mail however the message txt does not show up in my mail.

\<?PHP  
$to = "me@hotmail.com";  
$messsage = "$name

";  
$messsage = "$message

";  
mail($to, $msg, "From: My web site  
Reply-To: $email  
");

echo “passed”;  
?\>

THX

---

<div class="post-metadata">

**Author:** ![Ankou](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ankou/32/1351_2.png) [@Ankou](https://forum.kirupa.com/u/Ankou)\
**Post date:** [April 20, 2006, 7:06pm UTC](https://forum.kirupa.com/t/super-simple-script-rewrite/186282/2 "2006-04-20T19:06:19Z")

</div>

PHP’s mail() function is:

```php
mail( $to, $subject, $message, $headers );

```

Your code… well I’m not sure what it’s doing. Looks like the $to is fine. The $msg … I don’t see that defined anywhere. If that’s the message, it’s in the wrong spot. You need the subject of the email before the message.

Your Code:

```php
<?PHP
$to = "me@hotmail.com";
$messsage = "$name

";
$messsage = "$message

";
mail($to, $msg, "From: My web site
Reply-To: $email
");

echo "passed";
?>

```

Try:

```php
<?PHP
$to = "me@hotmail.com";
$messsage = "$name

";
$messsage = "$message

";
$headers = 'From: My web site' . "
" . 'Reply-To: ' . $email;

if(mail($to, "Put in a subject", $message, $headers)){
  echo "passed";
}else{
  echo "failed";
}

?>

```

You may want to check the PHP in that since I did it off the top of my head. It may need to be tweaked a bit.

---

<div class="post-metadata">

**Author:** ![sebjo](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@sebjo](https://forum.kirupa.com/u/sebjo)\
**Post date:** [April 20, 2006, 8:32pm UTC](https://forum.kirupa.com/t/super-simple-script-rewrite/186282/3 "2006-04-20T20:32:54Z")

</div>

Ankou THx so much for taking the time to rewrite the script. I tried it on my server but am still getting the same results. I have tried to tweak some things myself but am having no luck probably do to the fact that I have no knowledge of PHP whatsoever.

If someone can spot the error it would be fantastic

---

<div class="post-metadata">

**Author:** ![Ankou](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ankou/32/1351_2.png) [@Ankou](https://forum.kirupa.com/u/Ankou)\
**Post date:** [April 20, 2006, 9:39pm UTC](https://forum.kirupa.com/t/super-simple-script-rewrite/186282/4 "2006-04-20T21:39:10Z")

</div>

```php
<?PHP
$to = "me@hotmail.com";
$messsage = "$name

";
$messsage = "$message

";
$headers = 'From: My web site' . "
" . 'Reply-To: ' . $email;

if(mail($to, "Put in a subject", $message, $headers)){
  echo "passed";
}else{
  echo "failed";
}

?> 

```

I see…

Above is the code I put… there’s a few things that need changing. I didn’t notice that you had:

```php
$messsage = "$name

";
$messsage = "$message

";

```

Notice that it’s $messsage – there’s an extra ‘s’ in there. And the second $messsage = "$message

"; should have a .=

I assume you have $messsage because you already had a variable named $message and didn’t want to overwrite it. So you may have added an extra ‘s’ in there to make sure that didn’t happen. Good to do - but bad thing to use a variable name so similar to another one. I changed $messsage to $sendMessage.

Try:

```php
<?PHP
$message = "Test Message";
$name = "Chuck";
$email = "email@noplace.com";
// The above were used just to test the script - you can remove them if needed.

$to = "me@hotmail.com";
$sendMessage = "$name

";
$sendMessage .= "$message

";
$headers = 'From: My web site' . "
" . 'Reply-To: ' . $email;

if(mail($to, "Put in a subject", $sendMessage, $headers)){
  echo "passed";
}else{
  echo "failed";
}

?>

```

---

<div class="post-metadata">

**Author:** ![sebjo](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@sebjo](https://forum.kirupa.com/u/sebjo)\
**Post date:** [April 21, 2006, 12:20am UTC](https://forum.kirupa.com/t/super-simple-script-rewrite/186282/5 "2006-04-21T00:20:16Z")

</div>

THX for your help.

Its working now

---

<div class="post-metadata">

**Author:** ![Ankou](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ankou/32/1351_2.png) [@Ankou](https://forum.kirupa.com/u/Ankou)\
**Post date:** [April 21, 2006, 12:52am UTC](https://forum.kirupa.com/t/super-simple-script-rewrite/186282/6 "2006-04-21T00:52:24Z")

</div>

No problem. Glad it’s working. :thumb2:
