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">

&nbsp;&nbsp;Hello This Is firecraftgaming.com's newsMail.

<br>

&nbsp;&nbsp;2

<br>

&nbsp;&nbsp;3

<br>

&nbsp;&nbsp;4

<br>

&nbsp;&nbsp;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





You could benefit from using a library like PHPMailer or SwiftMailer
– Nico Haase
Jul 1 at 7:43





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.

Popular posts from this blog

List of Kim Possible characters

Audio Livestreaming with Python & Flask

NSwag: Generate C# Client from multiple Versions of an API