diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 94fb05d5346..7acd7ac3db0 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2019-2020 Frédéric France + * Copyright (C) 2019-2022 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -547,10 +547,18 @@ class CMailFile } if (!empty($this->addr_cc)) { - $this->message->setCc($this->getArrayAddress($this->addr_cc)); + try { + $this->message->setCc($this->getArrayAddress($this->addr_cc)); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } } if (!empty($this->addr_bcc)) { - $this->message->setBcc($this->getArrayAddress($this->addr_bcc)); + try { + $this->message->setBcc($this->getArrayAddress($this->addr_bcc)); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } } //if (! empty($this->errors_to)) $this->message->setErrorsTo($this->getArrayAddress($this->errors_to)); if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) {