This commit is contained in:
Finley Ghosh 2025-11-20 23:12:44 +11:00
parent 4ae4ca097a
commit da4eefdbf6

View file

@ -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);