PHPBuilder - Simple form mail

RSS Twitter

Simple form mail

by: Olaf Lederer
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.

$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>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Mailer: Olaf's formmail version 1.10\r\n";
$header .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$header .= "Content-Transfer-Encoding: 8bit\r\n";
$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 . "\r\n";
mail("", $subject, $body, $header);
header("Location: ".$goto_after_mail);

Comment and Contribute

Your comment has been submitted and is pending approval.

Olaf Lederer



(Maximum characters: 1200). You have characters left.