# Beginner\_php contact from not working

**URL:** <https://www.phphelp.com/t/beginner-php-contact-from-not-working/12860>\
**Category:** General PHP Help\
**Created:** [March 11, 2011, 8:54pm UTC](https://www.phphelp.com/t/beginner-php-contact-from-not-working/12860 "2011-03-11T20:54:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://www.phphelp.com/uploads/default/original/2X/2/243e9ed5d93c5653ce3186f18df16e019ce38445.png) [@system](https://www.phphelp.com/u/system)\
**Post date:** [March 11, 2011, 8:54pm UTC](https://www.phphelp.com/t/beginner-php-contact-from-not-working/12860/1 "2011-03-11T20:54:33Z")

</div>

My contact form is not sending email. Please help!?  
I am new to the whole php thing. I recently created a contact form following a few tutorials. I followed them and did exactly as the presenter told me to do. When I test the form, I get the success confirmation, but the actual email from is not sent to the webmaster specified. Can someone take a look at my code and let me know where I went wrong?

\<?php /\*Subject and email Variavbles \*/ $emailSubject = 'Ask a Designer Question'; $webMaster = 'torrance@centralkitchen.com'; /\* Gathering Data Variables \*/ $emailField = $\_POST['email']; $fnameField = $\_POST['fname']; $lnameField = $\_POST['lname']; $interestField = $\_POST['interest']; $commentsField = $\_POST['comments']; $newsletterField = $\_POST['newsletter']; $body = \<\<\<EOD  

* * *
  
Email: $email   
First Name: $fname   
Last Name: $lname   
Interest: $interest   
Comments: $comments   
Newsletter: $newsletter   
EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /\* Results rendered as HTML \*/ $theResults = \<\<\<EOD Ask a Designer Confirmation Page
  

* * *
  

Thank you for your interest! Your email will be answered by one of our designers very soon!
  

* * *
  

EOD; echo "$theResults"; ?\>

---

<div class="post-metadata">

**Author:** ![Redscouse](https://www.phphelp.com/user_avatar/www.phphelp.com/redscouse/32/124_2.png) [@Redscouse](https://www.phphelp.com/u/Redscouse)\
**Post date:** [March 12, 2011, 10:14am UTC](https://www.phphelp.com/t/beginner-php-contact-from-not-working/12860/2 "2011-03-12T10:14:56Z")

</div>

these variables here:  
[php]$emailField = $\_POST[‘email’];  
$fnameField = $\_POST[‘fname’];  
$lnameField = $\_POST[‘lname’];  
$interestField = $\_POST[‘interest’];  
$commentsField = $\_POST[‘comments’];  
$newsletterField = $\_POST[‘newsletter’];  
[/php]

are not the same as here:  
[php]$body = \<\<\<EOD

* * *
  
  
Email: $email   
  
First Name: $fname   
  
Last Name: $lname   
  
Interest: $interest   
  
Comments: $comments   
  
Newsletter: $newsletter   
  
EOD;  
[/php]

and you have the from email variable as $email but i can’t see where $email is set in the script??  
[php]$headers = “From: $email\r\n”;  
$headers .= “Content-type: text/html\r\n”;  
$success = mail($webMaster, $emailSubject, $body, $headers);[/php]

I take it these come from another script?  
i did try your script (obviously changing the variables to my own email address) and it works just fine.
