email - PHP contact form mail bad codification -
i have contact form , i'm having little bit of trouble codificatio. dont know why special characters (it's spanish) show badly in email received. i'm begginner in dont know problem. web declared in utf-8 , here code
<?php $name = $_post['name']; $email = $_post['email']; $message = $_post['message']; $from = 'from: web.com'; $to = 'email@email.com'; $subject = 'formulario contacto web'; $body = "nombre: $name<br> e-mail: $email<br> mensaje:<br> $message"; $headers = "mime-version: 1.0" . php_eol; $headers .= "content-type: text/html; charset=utf-8" . php_eol; $headers .= "from: " . $from . "\n"; if ($_post['submit']) { if (mail($to, $subject, $body, $headers)) { echo '<script type="text/javascript">alert("su mensaje ha sido enviado");</script>'; } else { echo '<script type="text/javascript">alert("algo ha ido mal. inténtelo de nuevo por favor");</script>'; } } ?>
update header;
$headers .= "content-type: text/html; charset=utf-8" . php_eol;
as
$headers .= 'content-type: text/plain; charset=utf-8' . "\r\n";
and state utf-8 thing in message html header like;
< meta charset="utf-8" />
Comments
Post a Comment