diff --git a/scripts/send_info_mailing_20190906.php b/scripts/send_info_mailing_20190906.php new file mode 100644 index 0000000..661e9bf --- /dev/null +++ b/scripts/send_info_mailing_20190906.php @@ -0,0 +1,142 @@ +#!/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"; diff --git a/scripts/send_info_mailing_20190906.sh b/scripts/send_info_mailing_20190906.sh new file mode 100755 index 0000000..5eafcaf --- /dev/null +++ b/scripts/send_info_mailing_20190906.sh @@ -0,0 +1,11 @@ +#! /bin/bash +# send_info_mailing_20190906.sh - script to run send_info_mailing_20190906.php in a loop +# This script is needed because the underlying PHP script appears to have a memory leak, +# so in order to avoid system memory exhaustion we run a loop around it. + +nextstep="Continue" +while [ ${nextstep} != "Stop" ] +do + php -f send_info_mailing_20190906.php | tee send_info_mailing_20190906_run.txt + nextstep=$(tail -1 send_info_mailing_20190906_run.txt) +done