Take the 2-minute tour ×

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


if (isset($_POST['submit_btn'])) {

$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'];



    $body_message ='newsletter html code';

    $headers .="Reply-to: $headers4\n";
    $headers .= "From: $headers4\n"; 
    $headers .= "Errors-to: $headers4\n"; 



    echo $i." sent to ".$email; 
    echo "<br>";

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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

share|improve this answer
I'm glad it's not just me who cant see an issue, where would one generally find said log? –  Xand94 Jun 2 '11 at 11:30
/var/log/maillog but it could vary based on your linux. Anyway you said your first 70-80 went fine and then the others no. Are you using another script for this others? Why they are splitted in two groups? –  dynamic Jun 2 '11 at 11:31
bummer, don't have access to that directory i believe. they are two different newsletters for different sites. the first 80 did go fine, and all i really did was copy and paste bits into the new script and fix up accordingly. I have proof read the hell out of them both though and cannot see anything –  Xand94 Jun 2 '11 at 11:35
HMMM if you copy paste for the second group and the first group is working maybe you added some errors in the second script. –  dynamic Jun 2 '11 at 11:36
well it wasn't just a copy paste, i mainly just pulled the sql and if code accross. I have managed to get into mail.log and cannot see anything out of the ordinary. –  Xand94 Jun 2 '11 at 11:38
show 6 more comments

Your Answer


