vic3685 Posted January 20, 2010 Share Posted January 20, 2010 Hi everyone, I'm a bit puzzled by a contact form that is not working properly. I'm from Argentina, so we use accents and some other special characters, which are giving me a hard time. Now I changed the charset to UTF-8, and here's what puzzles me: it works when it goes to my Hotmail account, but doesn't work when going to my client's account. I would say it's a mail server issue, not something with the form itself, do you agree? Is there a way around this? I'd love to hear suggestions. Thank you for hour help! Vicky Link to comment https://forums.phpfreaks.com/topic/189166-charsets/ Share on other sites More sharing options...
vic3685 Posted January 22, 2010 Author Share Posted January 22, 2010 Anybody? Here's the code I'm using: <?php // Define your email address - where to send messages - here define("MAIL_TARGET","[email protected]"); // Here you can redefine error messages define("errorName","Nombre no valido"); define("errorEmail","Direccion de email no valida!"); define("errorMsg","Debe tener por lo menos 10 caracteres"); function createForm($name="",$email="",$message="",$error1="",$error2="",$error3=""){ ?> ------------ <?php } function isValidEmail($email){ $pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"; if (eregi($pattern, $email)){ return true; } else { return false; } } function sendMail($name,$email,$message){ $subject = "contacto de pag web"; $from = "From: $name <$email>\r\nReply-To: $email\r\n"; $header = "MIME-Version: 1.0\r\n"."Content-type: text/html; charset=utf-8\r\n"; $content = htmlspecialchars($message); $content = wordwrap($content,70); mail(MAIL_TARGET,$subject,$content,$from.$header); } ?> --------- <?php if (!isset($_POST['submitBtn'])) { createForm(); } else { $name = isset($_POST['name']) ? $_POST['name'] : ""; $email = isset($_POST['email']) ? $_POST['email'] : ""; $message = isset($_POST['message']) ? $_POST['message'] : ""; $error = false; if (strlen($name)<2) { $error = true; $error1 = errorName; } if (!isValidEmail($email)) { $error = true; $error2 = errorEmail; } if (strlen($message)<10) { $error = true; $error3 = errorMsg; } if ($error){ createForm($name,$email,$message,$error1,$error2,$error3); } else { sendMail($name,$email,$message); ?> Link to comment https://forums.phpfreaks.com/topic/189166-charsets/#findComment-1000088 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.