Visitor: ' . $_POST["name"] . '
' . "\n"; $messageBody .= 'Email Address: ' . $_POST['email'] . '
' . "\n"; $messageBody .= 'State: ' . $_POST['state'] . '
' . "\n"; $messageBody .= 'Phone Number: ' . $_POST['phone'] . '
' . "\n"; $messageBody .= 'Fax Number: ' . $_POST['fax'] . '
' . "\n"; $messageBody .= 'Message: ' . $_POST['message'] . '
' . "\n"; } if($_POST["stripHTML"] == 'true'){ $messageBody = strip_tags($messageBody); } if($host=="" or $username=="" or $password==""){ $owner_email = $_POST["owner_email"]; $headers = 'From:' . $_POST["email"] . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n"; $subject = 'A message from your site visitor ' . $_POST["name"]; try{ if(!mail($owner_email, $subject, $messageBody, $headers)){ throw new Exception('mail failed'); }else{ echo 'mail sent'; } }catch(Exception $e){ echo $e->getMessage() ."\n"; } }else{ require_once 'Mail.php'; $to = $_POST["owner_email"]; $subject = 'A message from your site visitor ' . $_POST["name"]; $headers = array ( 'From' => 'From:' . $_POST["email"] . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n", 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory( 'smtp', array ( 'host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $messageBody); try{ if(PEAR::isError($mail)){ echo $mail->getMessage(); }else{ echo 'mail sent'; } }catch(Exception $mail){ echo $mail->getMessage() ."\n"; } } ?>