Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

civicrm/org.civicrm.flexmailer - Update mailing database after each mail is sent. #60

Open
spalmstr opened this issue Jun 20, 2020 · 1 comment

Comments

@spalmstr
Copy link

Flexmailer suffers from the same issue from which traditional CiviMail suffers as in dev/core#1768 - Update mailing database after each mail is sent. which refers to issue CiviMail mail job fails to complete, even though mail is sent, in that .../src/Listener/DefaultSender.php records successful sent emails every self::BULK_MAIL_INSERT_COUNT instead of every time it sends one. This means that if the job aborts prematurely, perhaps because PHP runs out of memory, it forgets the last few emails and sends them again when the job restarts. It might make sense to make this change, possibly adding an option just to record successful emails every self::BULK_MAIL_INSERT_COUNT if the administrator wants it.

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- a/<html>DefaultSender.php (<b>17 Jun 2020, 09:30:17</b>)</html>
+++ b/<html><b>Current File</b></html>
@@ -94,10 +94,12 @@
         // Register the delivery event.
         $deliveredParams[] = $task->getEventQueueId();
         $targetParams[] = $task->getContactId();
-
+        // Write every time to the database so we remember we have sent the
+        // even if the job should be aborted.
+        $job->writeToDB($deliveredParams, $targetParams, $mailing, $job_date);
         $count++;
         if ($count % self::BULK_MAIL_INSERT_COUNT == 0) {
-          $job->writeToDB($deliveredParams, $targetParams, $mailing, $job_date);
+          //$job->writeToDB($deliveredParams, $targetParams, $mailing, $job_date);
           $count = 0;
 
           // hack to stop mailing job at run time, CRM-4246.

@a-sassmannshausen
Copy link

Fwiw, I just ran into this same issue, leading to a civi deployment spamming some hapless contacts with hundreds of emails, because Civi kept restarting the scheduled mailing job only to fail halfway through the count.

I support the above proposition!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants