There are three requirements for sending email through a PHP script: A form, an email processing script, and PHP’s mail() function to be enabled (most hosts have this enabled, but some shared hosts don’t).
Place this inside a file called mail.html
[ad name=”In Post”]
The email processing script should be inside a file called mail.php:
if(!isset($_POST['receiver'], $_POST['sender'], $_POST['subject'], $_POST['message'])) die("Error sending email"); // check if the page is tried to be accessed directly (e.g. a hacking attempt)
$to = $_POST['receiver']; $from = $_POST['sender']; $subject = $_POST['subject']; $message = $_POST['message'];
$headers = "From: " . $from . "rn" . "Reply-To: " . $from . "rn" . "X-Mailer: PHP/" . phpversion();
$send = mail($to, $subject, $message, $headers);