El problema que tengo es que cuando se envía, los carácteres especial (ya sean tildes, ñ. etc) llegan mal al correo electrónico.
Probé usando la codificación ISO y UTF-8 tanto en la página del contacto como en el php que hace el envío y sigue sin funcionar...
(aclaro que la codificación la agregué en el código (<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />) y también cuando guarde el .txt (ANSI - UTF -8).
Lei en un montón de posts en el foro que es posible modificar los carácteres por código HTML (por ej: Á), lo intenté pero no estoy seguro donde agregarlo, y no funciona. Agradecería si alguien me puede dar una mano... dejo aquí el código del .JS y el .PHP por si alguien me puede ayudar:
JS
Código:
PHP$(function() { $('.error').hide(); $('input.text-input').css({backgroundColor:"#FFFFFF"}); $('input.text-input').focus(function(){ $(this).css({backgroundColor:"#FFDDAA"}); }); $('input.text-input').blur(function(){ $(this).css({backgroundColor:"#FFFFFF"}); }); $(".button").click(function() { // validate and process form // first hide any error messages $('.error').hide(); var inp1 = $("input#inp1").val(); if (inp1 == "") { $("label#inp1_error").show(); $("input#inp1").focus(); return false; } var inp2 = $("input#inp2").val(); if (inp2 == "") { $("label#inp2_error").show(); $("input#inp2").focus(); return false; } var inp3 = $("input#inp3").val(); if (inp3 == "") { $("label#inp3_error").show(); $("input#inp3").focus(); return false; } var dataString = 'inp1='+ inp1 + '&inp2=' + inp2 + '&inp3=' + inp3; //alert (dataString);return false; $.ajax({ type: "POST", url: "bin/process.php", data: dataString, success: function() { $('#contact_form').html("<div id='message'></div>"); $('#message').html("<h2>Formulario enviado con exito!</h2>") .append("<p>Proximamente recibira la respuesta</p>") .hide() .fadeIn(1500, function() { $('#message').append("<img id='checkmark' src='check.png' />"); }); } }); return false; }); }); runOnLoad(function(){ $("input#name").select().focus(); });
Código PHP:
<?php
if ((isset($_POST['inp1'])) && (strlen(trim($_POST['inp1'])) > 0)) {
$inp1 = stripslashes(strip_tags($_POST['inp1']));
} else {$inp1 = 'No inp1 entered';}
if ((isset($_POST['inp2'])) && (strlen(trim($_POST['inp2'])) > 0)) {
$inp2 = stripslashes(strip_tags($_POST['inp2']));
} else {$inp2 = 'No inp2 entered';}
if ((isset($_POST['inp3'])) && (strlen(trim($_POST['inp3'])) > 0)) {
$inp3 = stripslashes(strip_tags($_POST['inp3']));
} else {$inp3 = 'No inp3 entered';}
ob_start();
?>
<div style="width:641px;margin:0 auto;">
<table width="641" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Nombre: <?=$inp1;?></td>
</tr>
<tr>
<td>Apellido: <?=$inp2;?></td>
</tr>
<tr>
<td>Empresa: <?=$inp3;?></td>
</tr>
</table>
</div></body></html>
<?
$body = ob_get_contents();
$to = '[email protected]';
$email = '[email protected]';
$fromaddress = "[email protected]";
$fromname = "Online Contact";
require("phpmailer.php");
$mail = new PHPMailer();
$mail->From = "[email protected]";
$mail->FromName = "TEST";
$mail->AddAddress("[email protected]","Name 1");
$mail->AddAddress("[email protected]","Name 2");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "Asunto del formulario";
$mail->Body = $body;
$mail->AltBody = "This is the text-only body";
if(!$mail->Send()) {
$recipient = '[email protected]';
$subject = 'Contact form failed';
$content = $body;
mail($recipient, $subject, $content, "From: [email protected]\r\nReply-To: $email\r\nX-Mailer: DT_formmail");
exit;
}
?>
Saludos!