我尝试使用CKEditor或HTML编写的PHP发送电子邮件。当电子邮件发送时,HTML代码出现在电子邮件中,我知道但是Headers已经尝试过放大,但没有用。
以下是我发送电子邮件的代码。
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);
}
}
答案 0 :(得分:1)
你应该这样做..
mail()
而不是email()
[除非你为同一个编写了一个包装器] 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";
while (($row = mysql_fetch_assoc($query)) !== false){
mail($row['Email'], $titulo, "Olá " . $row['Nome'] . ",\n\n" . $conteudo, $header);
}
}
答案 1 :(得分:0)
试试这个我想你每次进入循环时都必须将标题留空。
并检查
@mail($ email,$ subject,$ message,$ headers);
最后一行相应地包含所有值。
function mail_users($titulo, $conteudo){
$query = mysql_query("SELECT `Email`, `Nome` FROM `utilizadores` WHERE `Newsletter` ='Ativada'");
while (($row = mysql_fetch_assoc($query)) !== false){
$header='';
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
@mail($row['Email'], $titulo, "Olá" . $row['Nome'] . ",\n\n" . $conteudo, $header);
}
}
答案 2 :(得分:0)
试试这个
function mail_users($titulo, $conteudo)
{
$header = "MIME-Version: 1.0\r\n";
$header .= "From: xyz@yourdomain.com";
$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$query = mysql_query("SELECT `Email`, `Nome` FROM `utilizadores` WHERE `Newsletter` = 'Ativada'");
while($row = mysql_fetch_assoc($query))
{
mail($row['Email'], $titulo, "Olá " . $row['Nome'] . ",\n\n" . $conteudo, $header);
}
}