64) {
// local part length exceeded
$isValid = false;
} else if ($domainLen < 1 || $domainLen > 255) {
// domain part length exceeded
$isValid = false;
} else if ($local[0] == '.' || $local[$localLen - 1] == '.') {
// local part starts or ends with '.'
$isValid = false;
} else if (preg_match('/\\.\\./', $local)) {
// local part has two consecutive dots
$isValid = false;
} else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
// character not valid in domain part
$isValid = false;
} else if (preg_match('/\\.\\./', $domain)) {
// domain part has two consecutive dots
$isValid = false;
} else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", "", $local))) {
// character not valid in local part unless
// local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", "", $local))) {
$isValid = false;
}
}
if ($isValid && !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"))) {
// domain not found in DNS
$isValid = false;
}
}
return $isValid;
}
$name = strip_tags(trim($_POST["name"]));
$lastname = strip_tags(trim($_POST["lastname"]));
$email = strip_tags(trim($_POST["email"]));
$message = strip_tags(trim($_POST["message"]));
$captcha =strip_tags(trim($_POST["ct_captcha"]));
$privacy =strip_tags(trim($_POST["privacy"]));
/* -------------------------------------------------------------------------
: Prepare serverside validation
------------------------------------------------------------------------- */
$errors = array();
$name_error=0;
$lastname_error=0;
$email_error=0;
$message_error=0;
$controllo = 0;
/* validate firstname
------------------------------------ */
if(isset($_POST["name"])){
if (!$name) {
$name_error=1;
$name_string= "Enter first name";
$controllo = 1;
} elseif(strlen($name) < 2) {
$name_error =1;
$name_string = "Enter at least 2 characters ";
$controllo = 1;
}
}
/* validate lastname
-------------------------------------- */
if(isset($_POST["lastname"])){
if (!$name) {
$lastname_error=1;
$lastname_string = "Enter last name";
$controllo = 1;
} elseif(strlen($lastname) < 2) {
$lastname_error=1;
$lastname_string = "Enter at least 2 characters";
$controllo = 1;
}
}
/* validate email address
-------------------------------------- */
if(isset($_POST["email"])){
if (!$email) {
$email_error=1;
$email_string = "Enter email address";
$controllo = 1;
} else if (!validEmail($email)) {
$email_error=1;
$email_string = "Enter a VALID email address";
$controllo = 1;
}
}
/* validate message
-------------------------------------- */
if(isset($_POST["message"])){
if (!$message) {
$message_error=1;
$message_string = "Enter message";
$controllo = 1;
}
}
/* validate message
-------------------------------------- */
if($_POST["privacy"] !="on"){
$controllo = 1;
$privacy_error= 1;
}
if(isset($_POST["ct_captcha"])){
require_once dirname(__FILE__) . '/securimage.php';
$securimage = new Securimage();
if ($securimage->check($captcha) == false) {
$captcha_error=1;
$controllo = 1;
/*$captcha_error = 'Incorrect security code entered
';*/
}
}
/* output all errors as a list
-------------------------------------- */
if ($controllo==0) {
include dirname(__FILE__).'/phpmailer/PHPMailerAutoload.php';
include dirname(__FILE__).'/templates/formmessage.php';
// Enter your name or company name below
$receiver_name = "MASTER TRIM";
// Enter your message subject below
$receiver_subject = "New Contact Message";
// The main email address for receiving the form message
$receiver_email = "communications@daneurope.org";
$mail = new PHPMailer();
//$mail->isSendmail();
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.daneurope.org'; // Specify main SMTP servers
$mail->SMTPAuth = false; // Enable SMTP authentication
$mail->Username = 'your-smtp-username'; // SMTP username
$mail->Password = 'your-smtp-password'; // SMTP password
//$mail->SMTPSecure = 'tsl'; // Enable encryption, 'tls' also accepted
$mail->Port = 25;
$mail->IsHTML(true);
$mail->From = $email;
$mail->CharSet = "UTF-8";
$mail->FromName = $name;
$mail->Encoding = "base64";
$mail->Timeout = 200;
$mail->ContentType = "text/html";
$mail->addAddress($receiver_email, $receiver_name);
$mail->Subject = $receiver_subject;
$mail->Body = $goldmessage;
$mail->AltBody = "Use an HTML compatible email client";
/* -------------------------------------------------------------------
: Prepare sending to multiple addresses / recepients if true
------------------------------------------------------------------- */
// If you want the form to be emailed to other addresses
// Change the extra_recipients option below from (false) to (true)
// Then enter email addresses with corresponding names seperated by comas
// For example "john@example.com" => "John", "jack@example.com" => "Jack", "jeny@example.com" => "Jeny"
// echo $goldmessage;
// echo $automessage;
$recipients = false;
if($recipients == true){
$recipients = array(
"communications@daneurope.org" => "SuperAdmin",
);
foreach($recipients as $email => $name){
$mail->AddBCC($email, $name);
}
}
if($mail->Send()) {
/* ---------------------------------------------------------------------
: Send the auto responder message if its true
--------------------------------------------------------------------- */
if($autoResponder == true){
include dirname(__FILE__).'/templates/autoresponder.php';
$automail = new PHPMailer();
//$automail->isSendmail();
$automail->isSMTP();
$automail->Host = '100.0.0.224';
$automail->SMTPAuth = false;
$automail->Username = 'your-smtp-username';
$automail->Password = 'your-smtp-password';
//$automail->SMTPSecure = 'tsl';
$automail->Port = 25;
$automail->From = $email;
$automail->FromName = $receiver_name;
$automail->isHTML(true);
$automail->CharSet = "UTF-8";
$automail->Encoding = "base64";
$automail->Timeout = 200;
$automail->ContentType = "text/html";
$automail->AddAddress($emailaddress, $firstname);
$automail->Subject = "Thank you for contacting us";
$automail->Body = $automessage;
$automail->AltBody = "Use an HTML compatible email client";
$automail->Send();
}
echo '