mail() error someone please help!



<?php $name = $POST_['name']; $email = $POST_['email']; $subject = $POST_['subject']; $body = $POST_['query']; mail("", "$subject", "$body", "From: '$name' : '$email'"); ?>[/php]

MOD EDIT: Corrected Incorrect Usage of PHP bb code tags

Above is my php code to send an email with what a user types in the form. I am currently getting blank emails sent to my address and was wondering if someone can tell me where I went wrong.

This is probably something simple as I am a beginner and have had very little php experience.

All help is greatly appreciated.


echo/print out the indiviual pieces and make sure the variable is actually moving in. Oh and it’s $POST not $POST


I have tried this and the variables are not working. I have changed it to $_POST so it can’t be that.

Any ideas?


If indeed your code is like


<?php $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $body = $_POST['query']; mail("", "$subject", "$body", "From: '$name' : '$email'"); ?>


Then I would have to ask, how are you sending the info? What is the code for the submitting page? Is it using a POST for it’s METHOD? Is the ACTION pointing to the page that has the above code? Are there any errors being displayed? Is the error reporting turned on in the PHP.INI?

If the variables are not working (as you suggested), then I would look at how you are submitting them to thies page.


Can we see the new chunk of code?



Get an 0845 Local Rate Number To

Simple support is available by the below form:-


Email Address: 




For add-on support packages click here.


Above is the code I am using to submit the data. It can be previewed at[/url]


I am not 100 percent sure, but I do believe you need to have all of your FORM elementes enclosed in the tags.

<form method="POST" action="sent.php">
   Name:&nbsp; <input type="text" name="name" size="20"></p>
  <p>Email Address:&nbsp; <input type="text" name="email" size="20"></p>
  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Subject:&nbsp;
  <input type="text" name="subject" size="20"></p>
  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Query:&nbsp;
  <textarea rows="8" name="query" cols="32"></textarea></p>
  <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> 


It works :D

Thanks everyone for your help