From 29daa3ebb3bcb12fbd5c4eb42c62a5d6cc010fc1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 1 Jan 2017 19:45:05 +0100 Subject: [PATCH] Stop silently overwriting recipients in Email::addRecipient() --- wcfsetup/install/files/lib/system/email/Email.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wcfsetup/install/files/lib/system/email/Email.class.php b/wcfsetup/install/files/lib/system/email/Email.class.php index 4596cb7ec1..230c7bc613 100644 --- a/wcfsetup/install/files/lib/system/email/Email.class.php +++ b/wcfsetup/install/files/lib/system/email/Email.class.php @@ -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 -- 2.20.1