Merge pull request #129 from VasuLief/raw-headers

getRawHeaders
This commit is contained in:
Robert Hafner 2015-06-06 22:46:20 -07:00
commit eb76a808d1

View File

@ -43,6 +43,13 @@ class Message
*/ */
protected $imapStream; protected $imapStream;
/**
* This as an string which contains raw header information for the message.
*
* @var string
*/
protected $rawHeaders;
/** /**
* This as an object which contains header information for the message. * This as an object which contains header information for the message.
* *
@ -291,6 +298,22 @@ class Message
return $this->messageOverview; return $this->messageOverview;
} }
/**
* This function returns an object containing the raw headers of the message.
*
* @param bool $forceReload
* @return string
*/
public function getRawHeaders($forceReload = false)
{
if ($forceReload || !isset($this->rawHeaders)) {
// raw headers (since imap_headerinfo doesn't use the unique id)
$this->rawHeaders = imap_fetchheader($this->imapStream, $this->uid, FT_UID);
}
return $this->rawHeaders;
}
/** /**
* This function returns an object containing the headers of the message. This is done by taking the raw headers * This function returns an object containing the headers of the message. This is done by taking the raw headers
* and running them through the imap_rfc822_parse_headers function. The results are only retrieved from the server * and running them through the imap_rfc822_parse_headers function. The results are only retrieved from the server
@ -303,7 +326,7 @@ class Message
{ {
if ($forceReload || !isset($this->headers)) { if ($forceReload || !isset($this->headers)) {
// raw headers (since imap_headerinfo doesn't use the unique id) // raw headers (since imap_headerinfo doesn't use the unique id)
$rawHeaders = imap_fetchheader($this->imapStream, $this->uid, FT_UID); $rawHeaders = $this->getRawHeaders();
// convert raw header string into a usable object // convert raw header string into a usable object
$headerObject = imap_rfc822_parse_headers($rawHeaders); $headerObject = imap_rfc822_parse_headers($rawHeaders);