Add "from" header stub

This commit is contained in:
u_mulder 2023-05-10 18:09:07 +03:00 committed by Alexey
parent f73071ac22
commit c957e41478

View File

@ -205,6 +205,18 @@ class Message
const FLAG_SEEN = 'seen';
const FLAG_DRAFT = 'draft';
/**
* When there's no "from" header in the message, code
* ```
* $val = '<' . $address['address'] . '>';
* ```
* in `self::getAddresses()` causes error.
*
* To avoid this error, if "from" header not found
* then it will be stored as array with this value
*/
const NO_FROM_HEADER_STUB_VALUE = 'unknown_sender';
/**
* This constructor takes in the uid for the message and the Imap class representing the mailbox the
* message should be opened from. This constructor should generally not be called directly, but rather retrieved
@ -260,7 +272,14 @@ class Message
if (isset($headers->sender))
$this->sender = $this->processAddressObject($headers->sender);
$this->from = isset($headers->from) ? $this->processAddressObject($headers->from) : array('');
$this->from = isset($headers->from)
? $this->processAddressObject($headers->from)
: array(
array(
'address' => self::NO_FROM_HEADER_STUB_VALUE,
),
)
;
$this->replyTo = isset($headers->reply_to) ? $this->processAddressObject($headers->reply_to) : $this->from;
/* Finally load the structure itself */