From 4ae4ca097aa73b7595ed9c20529bfd0540d90de6 Mon Sep 17 00:00:00 2001 From: Finley Ghosh Date: Thu, 20 Nov 2025 23:05:52 +1100 Subject: [PATCH] trying again --- app/controllers/documents_controller.php | 4 +--- cake/libs/controller/components/email.php | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/documents_controller.php b/app/controllers/documents_controller.php index 9d078b09..951d1e01 100755 --- a/app/controllers/documents_controller.php +++ b/app/controllers/documents_controller.php @@ -1326,10 +1326,8 @@ function email_pdf_with_custom_recipients($id = null, $to = null, $cc = null, $b echo json_encode(array('success' => false, 'message' => $msg)); return; } else { - // Pass as array - modified CakePHP EmailComponent now supports arrays for TO field + // Pass as array - EmailComponent now properly handles arrays for TO field $this->Email->to = $toArray; - // Set the To header for display purposes - $this->Email->headers['To'] = implode(', ', $toArray); } $ccArray = $this->parse_email_to_array($cc); if (!empty($ccArray)) { diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index 79d4d53b..c2727f9d 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -446,7 +446,12 @@ class EmailComponent extends Object{ */ function __createHeader() { if ($this->delivery == 'smtp') { - $this->__header[] = 'To: ' . $this->__formatAddress($this->to); + // Handle both string and array for TO field + if (is_array($this->to)) { + $this->__header[] = 'To: ' . implode(', ', array_map(array($this, '__formatAddress'), $this->to)); + } else { + $this->__header[] = 'To: ' . $this->__formatAddress($this->to); + } } $this->__header[] = 'From: ' . $this->__formatAddress($this->from);