#native_company# #native_desc#
#native_cta#

Simple form mail

By Olaf Lederer
on December 16, 2004

Version: 1.1

Type: Sample Code (HOWTO)

Category: Other

License: GNU General Public License

Description: This short snippet will process your whole contact form. Just use the code in your (external) script and change the mail address. Tip: Use clear field names in your form. In the current version is the Mime-format supported.

<?php
$goto_after_mail = "thanks.htm";
//ver 1.10 added some headers, incl. Mime mail to be accepted by more mail servers
$from_mail = $_REQUEST['from_email'];
$from_name = $_REQUEST['from_name']; // use both value's on you form
$header = "From: "$from_name" <$from_mail>rn";
$header .= "MIME-Version: 1.0rn";
$header .= "Mailer: Olaf's formmail version 1.10rn";
$header .= "Content-Type: text/plain; charset="iso-8859-1"rn";
$header .= "Content-Transfer-Encoding: 8bitrn";
$subject = "your webform posted at".date("d-m-Y"); //your mailsubject incl. current date
foreach ($_REQUEST as $key => $val) {
    if ($key != "from_email" && $key != "from_name") { //skip, this values are already in the header
        $body .= $key . " : " . $val . "rn";
    }
}
mail("[email protected]", $subject, $body, $header);
header("Location: ".$goto_after_mail);
?>