我有一个代码可以将电子邮件发送到多个地址。到达目的地的电子邮件还包括html标签:
" Hello ,
<br /> tell me if you still see those characters "strange."
<br /> Hello.
<br /> Marco
<br /> "
我该如何克服这个问题?在这里,代码。
$mittente = $_POST['mittente'];
$destinatario = $row_iscritti['email'];
$oggetto = $_POST['oggetto'];
$messaggio = nl2br($_POST['messaggio']);
$allegato = $_FILES['allegato']['tmp_name'];
$allegato_type = $_FILES['allegato']['type'];
$allegato_name = $_FILES['allegato']['name'];
$headers = "From: " . $mittente;
$msg = "";
if (is_uploaded_file($allegato))
{
$file = fopen($allegato,'rb');
$data = fread($file, filesize($allegato));
fclose($file);
$data = chunk_split(base64_encode($data));
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed;\n";
$headers .= " boundary=\"{$mime_boundary}\"";
$msg .= "This is a multi-part message in MIME format.\n\n";
$msg .= "--{$mime_boundary}\n";
$msg .= "Content-Type: text/html; charset=\"UTF-8\"\n";
$msg .= "Content-Transfer-Encoding: 7bit\n\n";
$msg .= $messaggio . "\n\n";
$msg .= "--{$mime_boundary}\n";
$msg .= "Content-Disposition: attachment; filename=\"{$allegato_name}\"\n";
$msg .= "Content-Transfer-Encoding: base64\n\n";
$msg .= $data . "\n\n";
$msg .= "--{$mime_boundary}--\n";
}