Creating a Php Script to Mail Your Form

Php Mail Script

According to the form action in simple_form.html, you
 need a script called send_simpleform.php. The goal
 of this script is to accept the text in
 $_POST[sender_name], $_POST[sender_email],
and $_POST[message] format, send an e-mail, and
 display a confirmation to the Web browser.
Open a new file in your text editor.
Begin a PHP block, then start building a message string:

PHP script to process the form, send the mail






<?
$msg = "E-MAIL SENT FROM WWW SITE\n";

Continue building the message string by adding an entry for the sender's name:

$msg .= "Sender's Name:\t$_POST[sender_name]\n";


 Note  The next few steps will continue building the message string by concatenating smaller strings to form one long message string. Concatenating is a fancy word for "smashing together." The concatenation operator (. =) is used.


Continue building the message string by adding an entry for the sender's e-mail address:

$msg .= "Sender's E-Mail:\t$_POST[sender_email]\n";

Continue building the message string by adding an entry for the message:

$msg .= "Message:\t$_POST[message]\n\n";

The final line contains two new line characters to add additional white space at the end of the string.

Create a variable to hold the recipient's e-mail address (substitute your own):

$to = "you@youremail.com";

Create a variable to hold the subject of the e-mail:

$subject = "Web Site Feedback";

Create a variable to hold additional mailheaders:

$mailheaders = "From: My Web Site <> \n";

Add to the $mailheaders variable:

$mailheaders .= "Reply-To: $_POST[sender_email]\n\n";

Add the mail() function:

mail($to, $subject, $msg, $mailheaders);

Close your PHP block:

?>