private function doParseBoundary($boundary) { $result = array(); $prefix = "--" . $boundary; $this->consumeRegexp("/\n*/"); $this->consumeTo($prefix); $this->consume($prefix); while ($this->expects("\n")) { $content = $this->consumeTo("\n" . $prefix); $part = new Part(); $part->loadSource($content); if ($part->isMultipart()) { $result += $part->getParts(); } else { $result[] = $part; } $this->consume("\n" . $prefix); } return $result; }
/** * Test a email document with base64 encoding */ public function testEmailBase64() { $content = file_get_contents(__DIR__ . '/../../data/email_base64.txt'); $part = new Part($content); self::assertTrue($part->isMultiPart()); $this->setExpectedException('\\LogicException', "MultiPart content, there aren't body"); $part->getBody(); self::assertEquals('This is thé subject', $part->getHeader('Subject')); /** @var Part[] $parts */ $parts = $part->getParts(); self::assertEquals('This is the content', $parts[0]->getBody()); self::assertEquals('This is the côntént', $parts[1]->getBody()); }