I'm using the php mail function, it works kinda fine, i really don't like to use this function but will have to do for this one.
So the problem is, the special european characters are being shown in a funny way on the email, i tried to set the codification to iso-8859-1 and the same is happening:
$to = $eemail;
$subject = $campos[4];
$message = $campos[5];
$message = mb_convert_encoding($message, 'HTML-ENTITIES', 'iso-8859-1');
$from = $campos[1];
$headers = "From:".$from."
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
$headers .= "X-Priority: 3
";
$headers .= "X-Mailer: PHP". phpversion() ."
";
The rest is a basic mail form, sent through AJAX:
$(function() {
$(".submita").click(function() {
var nome = $('#nome').attr('value');
var email = $('#email').attr('value');
var telemovel = $('#telemovel').attr('value');
var loja = $('#loja').attr('value');
var assunto = $('#assunto').attr('value');
var mensagem = $('#mensagem').attr('value');
var dataString = 'nome='+ nome + '&email=' + email + '&telemovel=' + telemovel + '&loja=' + loja + '&assunto=' + assunto + '&mensagem=' + mensagem;
$.ajax({
type: "POST",
url: "ajaxload/conemail.php",
data: dataString,
success: function() {
$(".mensagem").fadeIn();
}
});
return false;
});
});
What is going wrong?
chk this link from php.net
http://php.net/manual/en/function.mail.php
Hope this helps, this is the small content from this php.net page I gave url of
Sending messages with polish special characters:
<?php
function plmail($mail, $sub, $mes){
$headers = "From: ExRobot <robot@example.com>
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-type: text/plain; charset=utf-8
";
$headers .="Content-Transfer-Encoding: 8bit";
$mes=htmlspecialchars_decode($mes,ENT_QUOTES);//optional - I use encoding to POST data
mail($mail, "=?utf-8?B?".base64_encode($sub)."?=", $mes, $headers);
}
?>
Page must be in utf-8 encoding.
if your encoding or "codification" is different across platforms (ie the message/email, form, web browser, etc) you will get weird results...
most of the time you will want to go with utf-8
edit, if you cant get away with using utf-8, but have control of the page that displays the message, you could set a meta tag
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">