Skip to content

Commit

Permalink
Merge pull request #67 from pako-pl/master
Browse files Browse the repository at this point in the history
Add getRawHeader() method to allow retrieving headers without charset conversion
  • Loading branch information
eXorus committed Nov 12, 2015
2 parents 44b2cf9 + aaebb5a commit 96e852e
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,36 @@ private function parse()
}

/**
* Retrieve a specific Email Header
* Retrieve a specific Email Header, without charset conversion.
* @return String
* @param $name String Header name
*/
public function getHeader($name)
public function getRawHeader($name)
{
if (isset($this->parts[1])) {
$headers = $this->getPart('headers', $this->parts[1]);
return (isset($headers[$name])) ? $this->decodeHeader($headers[$name]) : false;
return (isset($headers[$name])) ? $headers[$name] : false;
} else {
throw new \Exception(
'setPath() or setText() or setStream() must be called before retrieving email headers.'
);
}
}

/**
* Retrieve a specific Email Header
* @return String
* @param $name String Header name
*/
public function getHeader($name)
{
$rawHeader = $this->getRawHeader($name);
if ($rawHeader === false) {
return false;
}
return $this->decodeHeader($rawHeader);
}

/**
* Retrieve all mail headers
* @return Array
Expand Down

0 comments on commit 96e852e

Please sign in to comment.