From dadc7dea1e2c76881347c3ecc0918d510ec6f7f8 Mon Sep 17 00:00:00 2001 From: Wytze van der Raay Date: Sat, 7 Sep 2019 13:24:59 +0000 Subject: [PATCH] Add scripts for mass info mailing on Sep 6 & 7, 2019. --- scripts/send_info_mailing_20190906.php | 142 +++++++++++++++++++++++++ scripts/send_info_mailing_20190906.sh | 11 ++ 2 files changed, 153 insertions(+) create mode 100644 scripts/send_info_mailing_20190906.php create mode 100755 scripts/send_info_mailing_20190906.sh 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