$e =
(new Email())->
from('me@example.com'
)->
to('you@example.com'
);
$e->
html($r);
// embedding the same image twice results in one image only in the email
$image =
fopen(__DIR__.'/Fixtures/mimetypes/test.gif', 'r'
);
$e->
addPart((new DataPart($image, 'test.gif'
))->
asInline());
$e->
addPart((new DataPart($image, 'test.gif'
))->
asInline());
$body =
$e->
getBody();
$this->
assertInstanceOf(RelatedPart::
class,
$body);
// 2 parts only, not 3 (text + embedded image once)
$this->
assertCount(2,
$parts =
$body->
getParts());
$this->
assertStringMatchesFormat('html content <img src=3D"cid:%s@symfony">',
$parts[0
]->
bodyToString());
$e =
(new Email())->
from('me@example.com'
)->
to('you@example.com'
);
$e->
html('<div background="cid:test.gif"></div>'
);
$e->
addPart((new DataPart($image, 'test.gif'
))->
asInline());
$body =
$e->
getBody();
$this->
assertInstanceOf(RelatedPart::
class,
$body);
$this->
assertCount(2,
$parts =
$body->
getParts());
$this->
assertStringMatchesFormat('<div background=3D"cid:%s@symfony"></div>',
$parts[0
]->
bodyToString());
} private function generateSomeParts(): array
{