Mega Code Archive

 
Categories / Php / Email
 

Simple form mail

<?php /* 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_mail\" <$from_name>\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Mailer: 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("you@yourmail.com", $subject, $body, $header); header("Location: ".$goto_after_mail); ?>