PHP mail ser fel ut i dator.
Hej.
Jag försöker att hitta vad som är fel då mail ser helt fel ut i mailprogram i datorer men rätt på smartphones och plattor. Jag har två filer Send.mail.php och mail.inc.php och jag kan inte för mitt liv se vad som skapar denna output
Någon som kan hjälpa till? Det syns kod i ämnes- meddelande- och bifogatfältet.
**Send.mail.php**
<?php header("Content-Type: text/html; charset=iso-8859-1");
include_once("php_includes/check_login_status.php");
// If user is already logged in, header that weenis away
if($user_ok != true){
header("location: secure.php");
exit();
}
include_once("php_includes/db_conx.php");
include_once("php_includes/init.inc.php");
$query = "SELECT email FROM xxxxx2 WHERE regional = 1 OR regional = 2";
$result=mysqli_query($db_conx, $query);
while ($row = mysqli_fetch_array($result)) {
$email = $row["email"];
if (isset($_POST['name'], $_FILES['file'])) {
$body = <<<BODY
Ämne:<br>
{$_POST['name']}
<p>
Meddelande:<br>
{$_POST['meddelande']}
BODY;
mail_file($email, 'auto_responder@xxxxxx.se', 'Svemod Mail', $body, $_FILES['file']);
}
}
?>
<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="Expires" CONTENT="Mon, 27 Jul 1997 00:00:00 GMT" />
<META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache" />
<title>Xxxxxx - Mail</title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="styles/style.css">
<style type="text/css">
<!--
tr:hover{
background: #333;
}
.style1 {color: #FF0000}
-->
</style>
</head>
<body bgcolor="#000000">
<?php include_once("template_pageTop.php"); ?>
<div id="pageMiddle">
<form action="" method="post" enctype="multipart/form-data">
<table align="center">
<tr>
<td>Skriv nytt meddelande (glöm inte skriva i meddelandet vem avsändaren är)</td>
</tr>
<tr>
<td class="style1">OBS! Klicka bara 1 gång. Det tar någon minut innan nästa sida kommer fram. OBS!</td>
</tr>
<tr>
<td><label for="name">Ämne</label></td>
</tr>
<tr>
<td><input type="text" name="name" id="name" /></td>
</tr>
<tr>
<td><label for="meddelande">Meddelande</label></td>
</tr>
<tr>
<td><textarea name="meddelande" id="meddelande" cols="50" rows="10" wrap="hard"></textarea></td>
</tr>
<tr>
<td><label for="file">Välj fil</label></td>
</tr>
<tr>
<td><input type="file" name="file" id="file" /></td>
</tr>
<tr>
<td><input type="submit" value="Skicka mail" /></td>
</tr>
</table>
</form>
</div>
<?php include_once("template_pageBottom.php"); ?>
</body>
</html>
**mail.inc.php**
<?php header("Content-Type: text/html; charset=iso-8859-1");
function mail_file($to, $from, $subject, $body, $file) {
$boundary = md5(rand());
$headers = array(
'MIME-Version: 1.0',
"Content-Type: multipart/mixed; boundary=\"{$boundary}\"",
"Content-type: text/html; charset=iso-8859-1",
"From: {$from}"
);
$message = array(
"--{$boundary}",
'Content-Type: text/HTML; charset=iso-8859-1',
'Content-Transfer-Encoding: 7bit',
'',
chunk_split($body),
"--{$boundary}",
"Content-Type: {$file['type']}; name=\"{$file['name']}\"",
"Content-Disposition: attachment; filename=\"{$file['name']}\"",
"Content-Transfer-Encoding: base64",
'',
chunk_split(base64_encode(file_get_contents($file['tmp_name']))),
"--{$boundary}--",
'',
);
mail($to, $subject, implode("\r\n", $message), implode("\r\n", $headers));
}
?>