check($_POST['ccode']) == false) { $captchaError = true; $hasError = true; } //Checa si la trampa (honeypot captcha) está vacia if($_POST['ageCheck'] !== '') { $honeypotError = true; $hasError = true; } //Checa que no esté vacio el campo Nombre if(trim($_POST['contactName']) === '') { $nameError = 'Olvidaste escribir tu nombre.'; $hasError = true; } else $name = trim($_POST['contactName']); //Checa que sea una dirección email válida if(trim($_POST['email']) === '') { $emailError = 'Olvidaste tu dirección de email.'; $hasError = true; } else if (!is_email(trim($_POST['email']))) { $emailError = 'Dirección de email no válida.'; $hasError = true; } else $email = trim($_POST['email']); //Checa que hallan escrito un mensaje if(trim($_POST['message']) === '') { $messageError = 'Olvidaste escribir tu mensaje.'; $hasError = true; } else { if(function_exists('stripslashes') && function_exists('htmlspecialchars')) $message = htmlspecialchars(stripslashes(trim($_POST['message']))); else $message = trim($_POST['message']); } //Checa que la ID de la página "the_ID" sea numérica if(is_numeric($_POST['contactId'])) $contactId = $_POST['contactId']; else $hasError = true; //Si no hay ningún error, envía el email. if(!isset($hasError)) { $sendCopy = $_POST['sendCopy']; $keywords = array('%name%','%email%','%message%','%bloginfo%'); $replace = array($name, $email, $message, get_bloginfo()); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; $mail->Host = get_post_meta($contactId, "mailHost", true); #"smtp.dominio.com"; $mail->Port = get_post_meta($contactId, "mailPort", true); #25,465 (puerto); $mail->Username = get_post_meta($contactId, "mailUsername", true); #"contacto@tudominio.com"; $mail->Password = get_post_meta($contactId, "mailPassword", true); #"password"; $mail->From = get_post_meta($contactId, "mailFrom", true); #'noreply@tudominio.com'; #get_option('admin_email'); $mail->FromName = str_replace($keywords, $replace, get_post_meta($contactId, "mailFromName", true)); #get_bloginfo(); $mail->Subject = str_replace($keywords, $replace, get_post_meta($contactId, "mailSubject", true)); #'Contacto: ' . $name; $mail->AltBody = str_replace($keywords, $replace, get_post_meta($contactId, "mailText", true)); #"Envia: $name <$email>\n\n$message"; $mail->MsgHTML(str_replace($keywords, $replace, get_post_meta($contactId, "mailHTML", true))); #"

$name<$email>

$message

"; $mail->AddBCC(get_post_meta($contactId, "mailUsername", true), get_bloginfo()); if($sendCopy == true) $mail->AddAddress($email, $name); $mail->AddReplyTo($email, $name); $mail->IsHTML(true); $mail->AddCustomHeader('Mime-Version: 1.0\r\n'); $emailSent = $mail->Send(); } } //Obtener el Header get_header(); //Esta función (functions.php) agrega una acción para incluir el