Using the previous examples would automatically send an email out when you view the webpage. This is generally not the effect most people are going for. Using a FORM to gather information from the visitor and have it sent to an email is probably the most popular use.
form.html
The ACTION tells the form to send the information gathered to the processing script when the SUBMIT button is clicked. The NAME values will become variables when they reach the processing script. The input information becomes the variable values.
process.php
The $header area has been modified a bit from the previous examples. Since the form is gathering information from the visitor, this will enter the info and add the correct start and ending parts for the 4th mail variable.
form.html
<html>
<head>
<title> My Test Form </title>
</head>
<body>
Send us an comment about our site!<br />
<form action="process.php" method="post">
Subject for email : <input type="text" name="subject"><br />
Visitor email : <input type="text" name="from"><br />
Message : <textarea name="message" rows="3" cols="40"></textarea><br />
<input type="submit" value="Send the info">
<input type="reset" value="Clear the form">
</form>
</body>
</html>
<head>
<title> My Test Form </title>
</head>
<body>
Send us an comment about our site!<br />
<form action="process.php" method="post">
Subject for email : <input type="text" name="subject"><br />
Visitor email : <input type="text" name="from"><br />
Message : <textarea name="message" rows="3" cols="40"></textarea><br />
<input type="submit" value="Send the info">
<input type="reset" value="Clear the form">
</form>
</body>
</html>
The ACTION tells the form to send the information gathered to the processing script when the SUBMIT button is clicked. The NAME values will become variables when they reach the processing script. The input information becomes the variable values.
process.php
<?php
$to = "yourplace@somewhere.com";
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: " . $from . "\r\n";
$headers .= "Return-Path: " . $from . "\r\n";
if ( mail($to,$subject,$message,$headers) ) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}
?>
$to = "yourplace@somewhere.com";
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: " . $from . "\r\n";
$headers .= "Return-Path: " . $from . "\r\n";
if ( mail($to,$subject,$message,$headers) ) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}
?>
The $header area has been modified a bit from the previous examples. Since the form is gathering information from the visitor, this will enter the info and add the correct start and ending parts for the 4th mail variable.

