954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP Form Submit To Email

I am a novice at PHP, but I would like to create a simple form that sends to a single email upon Submit. I am running Apache and I don't get any errors, but I never receive my test emails? I press submit, and nothing. Can anybody tell me what I am doing wrong? Your help is greatly appreciated.

This is the code I have embedded in my contact_us.php file.



Name:

Email:

Message:

 



Separate file named sendmail.php.

<?php
$to = "j.crnjarich@comcast.net";
$email = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$subject = "Message from: $name";
$message = $_REQUEST['message'] ;
$headers = "noreply@YOURWEBSITE.com";
$body = "From: $name \n\n Email: $email \n\n Wesbite: $site \n\n Message: $message";
$sent = mail($to, $subject, $body, $headers) ;
if($sent)
{echo "";}
else
{echo "";}
?>

skiturtles
Newbie Poster
1 post since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

You cannot send mail from local servers for that you need a live server and its mail sending feature must be active.

Kannan R
Newbie Poster
8 posts since Nov 2010
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: