Technique
Use PHP’s built-in mail() function:
<?php
/* submitted data is $email, $name,$subject, $message and $to */
mail($to,
$subject,
$message,
“From: $emailrnReply-to: $emailrn”);
?>
Comments
The mail() function takes three required arguments: the e-mail address to which you want to send the e-mail, the subject of the e-mail, and the body of the message. The fourth argument is optional, but it enables you to give any extra headers, which should be separated by the standard <CRLF> (“rn”).
The preceding script sends an e-mail based on the user’s input. A form that might trigger this script would be something like the following (assuming the script in the solution is named mailer.php):
<form action=”mailer.php” method=”POST”>
To: <input type=”text” name=”to”><br>
From: <input type=”text” name=”email”><br>
Subject: <input type=”text” name=”subject”><br>
Message Body: <br>
<textarea rows=”10″ cols=”40″ name=”message”></textarea><br>
<input type=”submit” value=”Send your message”>
</form>