Use stable Message-ID in MailWorker
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 15 Feb 2021 14:04:57 +0000 (15:04 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 18 Feb 2021 15:25:21 +0000 (16:25 +0100)
wcfsetup/install/files/lib/system/worker/MailWorker.class.php

index b1fa466c31ad2fc879088b59161d8efb2a00879a..87112ff34cf858349196ead129f8258dda15235a 100644 (file)
@@ -59,6 +59,15 @@ class MailWorker extends AbstractWorker
         }
 
         $this->mailData = $userMailData[$this->parameters['mailID']];
+        if (!isset($this->mailData['message-id'])) {
+            $this->mailData['message-id'] = \sprintf(
+                'com.woltlab.wcf.mailWorker/%d/%s',
+                TIME_NOW,
+                \bin2hex(\random_bytes(8))
+            );
+            $userMailData[$this->parameters['mailID']] = $this->mailData;
+            WCF::getSession()->register('userMailData', $userMailData);
+        }
     }
 
     /**
@@ -121,6 +130,7 @@ class MailWorker extends AbstractWorker
     public function execute()
     {
         $email = new Email();
+        $email->setMessageID($this->mailData['message-id']);
         $email->setSubject($this->mailData['subject']);
         $from = new Mailbox(
             $this->mailData['from'],