Hi all, I've just thrown this script together: quite basic but my knowledge in PHP is limited.
All I want it to do is send an email to all emails in a table.
I've told it to print out numbers instead of send emails; And it works fine (Stops at 140, the number of stored emails).
I've also told it to just send an email to me and ignore the while loop when the script is run: it works fine, with the correct body, header, subject etc.
BUT when I tell it to actually start mailing, it'll send everyone "No Subject" and blank messages AND will not auto-stop (Keeps going and going). Can anyone help rectify this: Been bugging me for hours!
*Apologies, I see how the "Blank email" thing happens: Some un-needed variable declarations! Corrected that, but the infinite sending still persists.
$emailsubject = "Test Subject Here";
$emailbody = "Test Body Here
Format Test. ";
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
$query = "SELECT email FROM tableNameHere";
$result = mysql_query($query);
$fromaddress = "myEmailHere";
$count = 1;
while ($row = mysql_fetch_assoc($result))
mail($row['email'], $emailsubject, $emailbody, "From: " .$fromaddress. "\nX-Mailer: PHP 4.x");
echo $row['email'] . "has been sent the email! ($count)<br /> ";