#!/usr/bin/php -q '$lastid' ORDER BY `id`"; $res = mysql_query($query); while($row = mysql_fetch_assoc($res)) { // $mailtxt = "Dear ${row["fname"]} ${row["lname"]},\n".$lines_EN."\n\n"; $mailtxt = "Dear Member of the CAcert-Community\n".$lines_EN."\n\n"; sendmail($row['email'], "[CAcert.org] Is there still a future for CAcert? (essential information)", $mailtxt, "support@cacert.org", "", "", "CAcert", "returns@cacert.org", ""); $fp = fopen("send_info_mailing_20190906_lastid.txt", "w"); fputs($fp, $row["id"]."\n"); fclose($fp); $count++; echo "Sent ${count}th mail. User ID: ${row["id"]}\n"; if(0 == $count % 8) { sleep (1); } if ($count >= 2000) { // avoid memory exhaustion -- this script has a memory leak echo "Continue\n"; exit(0); } } echo "Stop\n";