Stop silently overwriting recipients in Email::addRecipient()
authorTim Düsterhus <duesterhus@woltlab.com>
Sun, 1 Jan 2017 18:45:05 +0000 (19:45 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Sun, 1 Jan 2017 18:45:05 +0000 (19:45 +0100)
wcfsetup/install/files/lib/system/email/Email.class.php

index 4596cb7ec1b3157eb2fec6794269a0686cc07a5d..230c7bc6139d2680babddbc208b4cc0187be1280 100644 (file)
@@ -308,6 +308,10 @@ class Email {
                                throw new \DomainException("The given type '".$type."' is invalid. Must be one of 'to', 'cc', 'bcc'.");
                }
                
+               if (isset($this->recipients[$recipient->getAddress()])) {
+                       throw new \UnexpectedValueException("There already is a recipient with the email address '".$recipient->getAddress()."'. If you want to change the \$type use removeRecipient() first.");
+               }
+               
                $this->recipients[$recipient->getAddress()] = [
                        'type' => $type,
                        'mailbox' => $recipient