trying again

This commit is contained in:
Finley Ghosh 2025-11-20 23:05:52 +11:00
parent 59c77fcf15
commit 4ae4ca097a
2 changed files with 7 additions and 4 deletions

View file

@ -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)); echo json_encode(array('success' => false, 'message' => $msg));
return; return;
} else { } 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; $this->Email->to = $toArray;
// Set the To header for display purposes
$this->Email->headers['To'] = implode(', ', $toArray);
} }
$ccArray = $this->parse_email_to_array($cc); $ccArray = $this->parse_email_to_array($cc);
if (!empty($ccArray)) { if (!empty($ccArray)) {

View file

@ -446,7 +446,12 @@ class EmailComponent extends Object{
*/ */
function __createHeader() { function __createHeader() {
if ($this->delivery == 'smtp') { 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); $this->__header[] = 'From: ' . $this->__formatAddress($this->from);