just done a little bit of code to send out a newsletter based on a sql table.
first one with 70/80 subscribers went off fine, now when i've moved to the second one that has around 250, the body_message of the email is repeated inside the email equally to the number of people on the mailing list, in this case I was sending emails with 250 duplicates of the content inside...
not sure whats wrong with the code, have stripped it down as much as i could and was wondering if someone could talk a look and hopefully point out the issue
<?php
$i=1;
if (isset($_POST['submit_btn'])) {
connect_newsletter();
$result = mysql_query("SELECT id, mail FROM test") or die('Could not connect. ' . mysql_error());
while ($row = mysql_fetch_array($result)) {
$email = $row['mail'];
$nid = $row['id'];
$ip=$_SERVER['REMOTE_ADDR'];
$ref="http://www.domain.co.uk";
$body_message ='newsletter html code';
$y_email="noreply@domain.co.uk";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers4=$y_email;
$headers .="Reply-to: $headers4\n";
$headers .= "From: $headers4\n";
$headers .= "Errors-to: $headers4\n";
$subject="subject";
mail($email,$subject,$body_message,$headers);
echo $i." sent to ".$email;
开发者_开发技巧 echo "<br>";
$i++;
}
}
?>
Watching your code that is not possibile because in the loop you safely reset the value of $body
and $subject
The problem could be somewhere else. Check your sendmail log
精彩评论