diff --git a/common/framework/mail.php b/common/framework/mail.php index 355ae4358..e6dffade5 100644 --- a/common/framework/mail.php +++ b/common/framework/mail.php @@ -542,6 +542,12 @@ class Mail */ public function send() { + // Reset Message-ID in case send() is called multiple times. + $random = substr(hash('sha256', mt_rand() . microtime() . getmypid()), 0, 32); + $sender = $this->message->getFrom(); reset($sender); + $id = $random . '@' . (preg_match('/^(.+)@([^@]+)$/', key($sender), $matches) ? $matches[2] : 'swift.generated'); + $this->message->getHeaders()->get('Message-ID')->setId($id); + $output = \ModuleHandler::triggerCall('mail.send', 'before', $this); if(!$output->toBool()) {