Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions PlancakeEmailParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,35 @@ private function extractHeadersAndRawBody()
preg_match('/([^:]+): ?(.*)$/', $line, $matches);
$newHeader = strtolower($matches[1]);
$value = $matches[2];
$this->rawFields[$newHeader] = $value;
if (is_array($this->rawFields[$newHeader]))
$this->rawFields[$newHeader][] = $value;
else if (isset($this->rawFields[$newHeader]))
$this->rawFields[$newHeader] = array($this->rawFields[$newHeader], $value);
else
$this->rawFields[$newHeader] = $value;
$currentHeader = $newHeader;
}
else // more lines related to the current header
{
if ($currentHeader) { // to prevent notice from empty lines
$this->rawFields[$currentHeader] .= substr($line, 1);
if (is_array($this->rawFields[$currentHeader])) {
$this->rawFields[$currentHeader][count($this->rawFields[$currentHeader]) - 1] .= substr($line, 1);
} else {
$this->rawFields[$currentHeader] .= substr($line, 1);
}
}
}
$i++;
}
}

/**
* @return array the parsed headers as associative array
*/
public function getHeaders()
{
return $this->rawFields;
}

/**
*
Expand Down