Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public function getMime()
*/
public function generateMessage($EOL = Mime::LINEEND)
{
if (! $this->isMultiPart()) {
$body = array_shift($this->parts);
$body = $body->getContent($EOL);
if (!$this->isMultiPart()) {
$part = current($this->parts);
$body = $part->getContent($EOL);
} else {
$mime = $this->getMime();

Expand Down Expand Up @@ -176,8 +176,8 @@ public function getPartContent($partnum, $EOL = Mime::LINEEND)
*/
protected static function _disassembleMime($body, $boundary)
{
$start = 0;
$res = array();
$start = 0;
$res = array();
// find every mime part limiter and cut out the
// string before it.
// the part before the first boundary string is discarded:
Expand Down Expand Up @@ -260,6 +260,7 @@ public static function createFromMessage($message, $boundary, $EOL = Mime::LINEE
}
$res->addPart($newPart);
}

return $res;
}
}
12 changes: 12 additions & 0 deletions test/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,16 @@ public function testDecodeMimeMessage()
$this->assertEquals('base64', $part2->encoding);
$this->assertEquals('12', $part2->id);
}

public function testNonMultipartMessageShouldNotRemovePartFromMessage()
{
$message = new Mime\Message(); // No Parts
$part = new Mime\Part('This is a test');
$message->addPart($part);
$message->generateMessage();

$parts = $message->getParts();
$test = current($parts);
$this->assertSame($part, $test);
}
}

0 comments on commit cd44572

Please sign in to comment.