Skip to content

Commit 9fcbc3d

Browse files
committed
[Mime] Fix attached inline part not related
1 parent 7b9fc09 commit 9fcbc3d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Symfony/Component/Mime/Email.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,12 @@ private function prepareParts(): ?array
480480
foreach ($this->attachments as $attachment) {
481481
foreach ($names as $name) {
482482
if (isset($attachment['part'])) {
483+
if ($attachment['part']->getPreparedHeaders()->getHeaderBody('Content-Disposition') === 'inline') {
484+
$inlineParts[] = $attachment['part'];
485+
486+
continue 2;
487+
}
488+
483489
continue;
484490
}
485491
if ($name !== $attachment['name']) {

src/Symfony/Component/Mime/Tests/EmailTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,12 @@ public function testGenerateBody()
344344
// 2 parts only, not 3 (text + embedded image once)
345345
$this->assertCount(2, $parts = $body->getParts());
346346
$this->assertStringMatchesFormat('html content <img src=3D"cid:%s@symfony">', $parts[0]->bodyToString());
347+
348+
$e = (new Email())->from('me@example.com')->to('you@example.com');
349+
$e->html('html content <img src="cid:test.gif">');
350+
$e->attachPart((new DataPart($image, 'test.gif'))->asInline());
351+
$body = $e->getBody();
352+
$this->assertInstanceOf(RelatedPart::class, $body);
347353
}
348354

349355
public function testAttachments()

0 commit comments

Comments
 (0)