Skip to content

Commit

Permalink
Message->setBody: Clear headers when adding multi-part body
Browse files Browse the repository at this point in the history
It is undesirable for these headers to remain from a previous single-part call. Solves laminas#265

Signed-off-by: Karel Vlk <[email protected]>
  • Loading branch information
vlk-charles authored Aug 30, 2024
1 parent 6d1c33d commit 6b2c5a7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,11 @@ public function setBody($body)

// Multipart content headers
if ($this->body->isMultiPart()) {
$mime = $this->body->getMime();

/** @var ContentType $header */
$header = $this->getHeaderByName('content-type', ContentType::class);
$header->setType('multipart/mixed');
$header->addParameter('boundary', $mime->boundary());
$this->clearHeaderByName('content-type');
$this->clearHeaderByName('content-transfer-encoding');
$this->getHeaderByName('content-type', ContentType::class)
->setType('multipart/mixed')
->addParameter('boundary', $this->body->getMime()->boundary());
return $this;
}

Expand Down

0 comments on commit 6b2c5a7

Please sign in to comment.