mail() newline in to header, possible injection
mail() newline in to header, possible injection
I have tried to send an news paper to all that has subscripted but now I am only testing but I got this error when I run my code
Error:
Warning: mail() [function.mail]: mail() - newline in to header, possible injection, mail dropped in index.php on line 19
Code:
<?php
$x = file("emails.txt");
$y = file("title.txt");
$y = $y[0];
$z = file("text.txt");
$a = "";
for ($v = 0; $v < count($z); $v++) {
$a .= $z[$v]."n";
}
$a = wordwrap($a, 70);
$headers = "";
$headers .= "X-Priority: 1 (Highest)rn";
$headers .= "X-MSMail-Priority: Highrn";
$headers .= "Importance: Highrn";
$headers .= "From: mail@firecraftgaming.comrn";
$headers .= 'MIME-Version: 1.0' . "n";
$headers .= 'Content-type: text/html; charset=iso-8859-1';
for ($i = 0; $i < count($x); $i++) {
if (mail($x[$i], $y, $a, $headers)) {
echo " True<br>";
} else {
echo " False<br>";
}
}
?>
emails.txt:
myname@domain.com
daddy@domain.com
title.txt:
my title
text.txt:
<style>
.vl {
border-left: 2px solid red;
height: 100%;
}
</style>
<body class="vl">
Hello This Is firecraftgaming.com's newsMail.
<br>
2
<br>
3
<br>
4
<br>
5
<br>
</body>
</html>
it sends email to the last email but not to the rest
and the script works fine when emails.txt are only:
myname@domain.com
or only:
daddy@domain.com
The
MIME-Version
header is missing a r
.– Adrian W
Jul 1 at 7:49
MIME-Version
r
i had an 'r' before but my friend sad that MIME-Version doesn't work with 'r'
– Eliyah Sundström
Jul 1 at 7:52
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
You could benefit from using a library like PHPMailer or SwiftMailer
– Nico Haase
Jul 1 at 7:43