1
Good, I’m trying to send an email in PHP that is written with CKEDITOR, that is HTML. When the email is sent the HTML code appears in the email, I know it’s from the Headers but I’ve tried to put lots and none works.
Below follows my code to send the email.
function mail_users($titulo, $conteudo){
$query = mysql_query("SELECT `Email`, `Nome` FROM `utilizadores` WHERE `Newsletter` = 'Ativada'");
while (($row = mysql_fetch_assoc($query)) !== false){
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
email($row['Email'], $titulo, "Olá " . $row['Nome'] . ",\n\n" . $conteudo, $header);
}
}
Solution found
function mail_users($titulo, $conteudo){
$query = mysql_query("SELECT `Email`, `Nome` FROM `utilizadores` WHERE `Newsletter` = 'Ativada'");
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$header .= "From: [email protected]\r\n";
$header .= "Return-Path: [email protected]\r\n";
while (($row = mysql_fetch_assoc($query)) !== false){
mail($row['Email'], $titulo, "Olá " . $row['Nome'] . "," . $conteudo, $header);
}
}
Are you sure you’re sending any HTML? Since Content-type is HTML o and n is not, I believe it is not interpreted as line breaking, try replacing it with <br><br>.
– Júnior
Luis, please post the solution as an Answer below.
– brasofilo