Please fill your details in below and we'll get back to you.
Enquiry Form
/* Script from http://www.stevedawson.com/article0015.php */
if (isset($_POST["op"]) && ($_POST["op"]=="send")) {
/******** START OF CONFIG SECTION *******/
// Select if you want to check form for standard spam text
$SpamCheck = "Y"; // Y or N
$SpamReplaceText = "*content removed*";
// Error message prited if spam form attack found
$SpamErrorMessage = "Malicious code content detected.
Your IP Number of ".getenv("REMOTE_ADDR")." has been logged.
";
/******** END OF CONFIG SECTION *******/
/* Get Form Data- add or amend as needed - use $_POST for PHP5 */
$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
$telephone = $HTTP_POST_VARS['telephone'];
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
// Set Mailer + Settings
include_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mail.customerdomain.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "outbound@customerdomain.com"; // SMTP username
$mail->Password = "password"; // SMTP password
// Set Sender/Recipient
$mail->From = $email;
$mail->FromName = $name;
$mail->AddAddress("email@youremailaddress.com", "Name of the recipient"); // Add the email address of the person of recipient
if ($SpamCheck == "Y") {
// Check for Website URL's in the form input boxes as if we block website URLs from the form,
// then this will stop the spammers wastignt ime sending emails
if (preg_match("/http/i", "$name")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$message")) {echo "$SpamErrorMessage"; exit();}
// Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer
$pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string
$name = preg_replace($pattern, "", $name);
$email = preg_replace($pattern, "", $email);
$telephone = preg_replace($pattern, "", $telephone);
$message = preg_replace($pattern, "", $message);
// Check for the injected headers from the spammer attempt
// This will replace the injection attempt text with the string you have set in the above config section
$find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i");
$email = preg_replace($find, "$SpamReplaceText", $email);
$telephone = preg_replace($find, "$SpamReplaceText", $telephone);
$name = preg_replace($find, "$SpamReplaceText", $name);
$message = preg_replace($find, "$SpamReplaceText", $message);
// Check to see if the fields contain any content we want to ban
if(stristr($name, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
if(stristr($message, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
// Do a check on the send email and subject text
if(stristr($sendto, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
if(stristr($subject, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
}
// Build the email body text
$msg = "
Name: $name
Email: $email
Telephone: $telephone
Message: $message
";
// Set Subject + Body + Settings
$mail->Subject = "Website Form: $subject";
$mail->Body = $msg;
$mail->WordWrap = 50; // set word wrap to 50 characters
// Check the email address enmtered matches the standard email address format
if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) {
echo "Message Send Failed:
It appears you entered an invalid email address
Click here to go back.
";
}
elseif (!trim($name)) {
echo "Message Send Failed:
Please go back and enter a Name
Click here to go back.
";
}
elseif (!trim($message)) {
echo "Message Send Failed:
Please go back and type a Message
Click here to go back.
";
}
elseif (!trim($email)) {
echo "Message Send Failed:
Please go back and enter an EmailClick here to go back.
";
}
// Sends out the email or will output the error message
elseif(!$mail->Send())
{
echo "Message could not be sent. ";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
else
echo "
Success - Message Sent
Thank you $name for your message.
We will respond as soon as possible.
";
}
else {
?>