0
Situation
I have an email newsletter system, on it is sent emails to customers every day, but I realized that when using accents like ´~'^
, the words disfigure getting like this: ÓAÃÃÃ
forward.
Well, I’ve tried to include <meta charset="UTF-8">
and other encodings but nothing changes but saving with UTF-8 encoding.
Información Importante
The subject also has the same problem, IE, the entire email, since subject to message come out with disfigured accents.
The code php
is like this:
<?php
$msg_para = $_POST["msg_para"];
$msg_assunto = $_POST["msg_assunto"];
$msg_tipo = $_POST["msg_tipo"];
$mensagem = $_POST["mensagem"];
if($msg_para == "todos"){
$sql = mysql_query("SELECT * FROM list-emails WHERE ativo = 'online'");
$total = mysql_num_rows($sql);
$mailok = 0;
$falha = 0;
while($lista = mysql_fetch_array($sql)){
$email = $lista["email"];
$cabecalho = "From: $a_nome <$a_email>";
$cabecalho .= "\nReply-To: $a_nome <$a_email>";
$cabecalho .= "\nContent-Type: $msg_tipo";
if(@mail($email,$msg_assunto,$mensagem,$cabecalho)){
$mailok = $mailok + 1;
$msg = "<font color=green>SUCESSO!</font>";
}
else{
$falha = $falha + 1;
$msg = "<font color=red>FALHA!</font>";
}
?>
<font face="Arial" size="2">Enviando para <b><?=$email?></b>...
<b><?=$msg?></b></font><br>
<?php } ?>
<script>alert("<?=$total?> e-mails deveriam ser enviados...\n<?=$mailok?>
foram mandados corretamente,\n<?=$falha?> falharam!\n") </script>
<?php
}
else{
$cabecalho = "From: $a_nome <$a_email>";
$cabecalho .= "\nReply-To: $a_nome <$a_email>";
$cabecalho .= "\nContent-Type: $msg_tipo";
if(@mail($msg_para,$msg_assunto,$mensagem,$cabecalho)){
$msg = "<font color=green>SUCESSO!</font>";
}
else{
$msg = "<font color=red>FALHA!</font>";
}
?>
<font face="Arial" size="2">Enviando para <b><?=$msg_para?></b>...
<b><?=$msg?></b></font><br><?php
}
}
else{
echo "<script>location.href='login.php'</script>";
}
?>
The full code can be checked here
Briefly I need some way to put encoding UTF-8 or any other that does not have problems with accents in the email.
@Edit 14/04/16 08:23 AM
One thing I realized is that the name of the email set in config.php
comes out with normal accents, the only fields that have this problem are the subject matter and that of message. The code of config.php
is like this:
<?php
$host = "4322-8922";
$usuario = "5";
$senha = "4";
$banco = "321";
mysql_connect($host,$usuario,$senha);
mysql_select_db($banco);
$a_nome = "Téstê dê Ácëñtõs StáckÔvèrFlôw";
$a_email = "[email protected]";
$formato_msg = "Text/HTML";
$confirm_assunto = "Confirmação de Email $a_nome"; //esse assunto é especificamente para a parte de newsletter
$titulo = "Máîs Úm Tèstê";
$url = "http://answall.com";
$url_sist = "http://answall.com";
?>
And the result of the e-mail is like this:
Using text converters is out of the question since sending email email is done directly by the system, this would cause a slowdown in the process.
Try this:
utf8_encode($msg);
– Ed Cesar
@Edcesar, I tried to put this in $msg_subject and $message but nothing has changed, have any idea what it might be ?
– João Victor Gomes Moreira