diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index c2727f9d..e6377feb 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -447,11 +447,18 @@ class EmailComponent extends Object{ function __createHeader() { if ($this->delivery == 'smtp') { // Handle both string and array for TO field + error_log("[EmailComponent] Creating TO header. \$this->to = " . print_r($this->to, true)); + error_log("[EmailComponent] is_array(\$this->to) = " . (is_array($this->to) ? 'true' : 'false')); if (is_array($this->to)) { - $this->__header[] = 'To: ' . implode(', ', array_map(array($this, '__formatAddress'), $this->to)); + $formatted = implode(', ', array_map(array($this, '__formatAddress'), $this->to)); + error_log("[EmailComponent] Formatted TO addresses: " . $formatted); + $this->__header[] = 'To: ' . $formatted; } else { - $this->__header[] = 'To: ' . $this->__formatAddress($this->to); + $formatted = $this->__formatAddress($this->to); + error_log("[EmailComponent] Formatted TO address (single): " . $formatted); + $this->__header[] = 'To: ' . $formatted; } + error_log("[EmailComponent] TO header added: " . end($this->__header)); } $this->__header[] = 'From: ' . $this->__formatAddress($this->from);