Email Form
To: Laboratory of Personalized Health (lph@genomas.net)
Your e-mail:
Your Name:
Return to contact page
"; } elseif($p == "submit") { //Check for errors in the fields $error_message = ""; //Check values for email if($email == "") { $error_message .= "Enter your e-mail address
"; $error = $error+1; } if($email != "") { //Check for valid e-mail address if (!preg_match("/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$/", $email)) { $error_message .= "Enter a valid e-mail
"; $error = $error+1; } if (strlen($email) > 100 || strlen($email) < 6) { $error_message .= "Email must be 6-100 characters long
"; $error = $error+1; } } //Check values for name if($name == "") { $error_message .= "Enter your name
"; $error = $error+1; } if($name != "") { //name can only contain a-z, A-Z, spaces if (!preg_match("/^[a-zA-Z ]+$/", $name)) { $error_message .= "Your name can only contain letters and spaces
"; $error = $error+1; } if (strlen($name) > 100 || strlen($name) < 3) { $error_message .= "Your name must be 3-100 characters long
"; $error = $error+1; } } if($body == "") { $error_message .= "Enter a body for your e-mail
"; $error = $error+1; } if($error != 0) { if($error > 1) { $display_error = "Please correct the following $error errors:
$error_message
"; } else { $display_error = "Please correct the following error:
$error_message
"; } echo "
$display_error
Email Form
To: Laboratory of Personalized Health (lph@genomas.net)
Your e-mail:
Your Name:
Return to contact page
"; } elseif($error == 0) { $email = $_POST['email']; $name = $_POST['name']; $body = $_POST['body']; $body = preg_replace("/\n/", '
', $body); //Send activation e-mail $from = "Genomas LPH "; $to = "Laboratory of Personalized Health "; $subject = "Website Visitor Email"; $html = " Visitor's name: $name
Visitor's e-mail: $email
Body of e-mail:
$body "; $host = "smtp.exg6.exghost.com"; $port = "2525"; $username_login = "lph@genomas.net"; $password_login = "genomaslph"; // Create the Mail_Mime object: $mime = new Mail_Mime(); // Set the email body: //$mime->setTXTBody($text); $mime->setHTMLBody($html); // Set the headers: $mime->setFrom('lph@genomas.net'); $mime->setSubject("Website Visitor Email"); // Get the formatted code: $body = $mime->get(); $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username_login, 'password' => $password_login)); $headers = $mime->headers(); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { //echo("

" . $mail->getMessage() . "

"); } else { //echo("

Message successfully sent!

"); } echo "
E-mail successfully sent!
"; } } else { header('location: ' .$_SERVER['PHP_SELF']); } ?>