0
I have the following email class:
<?php
class EmailEnviarDao {
public function __construct() {}
public function enviaEmail($email) {
$enviaFormularioParaNome = $email->getNomeAlvo();
$enviaFormularioParaEmail = $email->getEmailAlvo();
$caixaPostalServidorNome = 'Hotplate Prensas';
$caixaPostalServidorEmail = '[email protected]';
$caixaPostalServidorSenha = '1234567890';
$remetenteNome = $email->getNomeRemete();
$remetenteEmail = $email->getEmailRemete();
$mensagem = $email->getDescricao();
$assunto = $email->getAssunto();
$qual = $email->getQual();
$mensagemConcatenada = '<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<?php header("Content-type: text/html; charset=utf-8");?>
<title>'.$caixaPostalServidorNome.'</title>
</head>
<body>
Formulário gerado via website<br/><br/><br/>
Nome: '.$remetenteNome.'<br/>
E-mail: '.$remetenteEmail.'<br/>
Assunto: '.$qual=="" ? $assunto : $qual.'<br/>
-------------------------------<br/><br/>
Mensagem: '.$mensagem.'
</body>';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Charset = 'UTF-8';
$mail->Host = 'smtp.'.substr(strstr($caixaPostalServidorEmail, '@'), 1);
$mail->Port = '587';
$mail->Username = $caixaPostalServidorEmail;
$mail->Password = $caixaPostalServidorSenha;
$mail->From = $remetenteEmail;
$mail->FromName = $remetenteNome;
$mail->IsHTML(true);
$mail->Subject = $assunto == "Outro Assunto" ? $qual : $assunto;
$mail->Body = $mensagemConcatenada;
$mail->AddAddress($enviaFormularioParaEmail,utf8_decode($enviaFormularioParaNome));
if($mail->Send()){
return array("success"=>1,"errors"=>"0K");
} else {
return array("success"=>0,"errors"=>"Não conseguimos enviar o e-mail");
}
}
}
?>
Everything works well, except the accents.
I have tried several alternatives published here in the forum but none worked.
The email is fired. But the accents, no!
I tried to put UTF-8 on htmls and
utf8_decode($mensagemConcatenada);
– user60252
thanks. it worked out!
– Carlos Rocha
Blz, I’ll put it in answer
– user60252