I have a code that sends emails to a number of addresses. The email that arrives at the destination also includes the html tags:
" Hello ,
<br /> tell me if you still see those characters "strange."
<br /> Hello.
<br /> Marco
<br /> "
How can I overcome this problem? Here, the code.
$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 .= "
MIME-Version: 1.0
";
$headers .= "Content-Type: multipart/mixed;
";
$headers .= " boundary=\"{$mime_boundary}\"";
$msg .= "This is a multi-part message in MIME format.
";
$msg .= "--{$mime_boundary}
";
$msg .= "Content-Type: text/html; charset=\"UTF-8\"
";
$msg .= "Content-Transfer-Encoding: 7bit
";
$msg .= $messaggio . "
";
$msg .= "--{$mime_boundary}
";
$msg .= "Content-Disposition: attachment; filename=\"{$allegato_name}\"
";
$msg .= "Content-Transfer-Encoding: base64
";
$msg .= $data . "
";
$msg .= "--{$mime_boundary}--
";
}