Skip to content

Commit 90140b4

Browse files
committed
minor #19946 [Mailer] Fixed and clarified custom Content-ID feature documentation (dakujem)
This PR was merged into the 6.4 branch. Discussion ---------- [Mailer] Fixed and clarified custom Content-ID feature documentation > Addresses [symfony/symfony #54162](symfony/symfony#54162) The documentation is incorrect, as it shows calls to `DataPart::setContentId` with strings that are rejected by [the method's implementation](https://github.com/symfony/symfony/blob/7.2/src/Symfony/Component/Mime/Part/DataPart.php#L66), because they do not contain a required `@` character. ![image](https://github.com/symfony/symfony/assets/443067/560fd816-e4d2-4a48-8d82-ef7dfa38db16) I also added a sentence clarifying that the actual Content-ID value will be ramdom-generated by Symfony when not using a custom Content-ID. This feature has been added in `v6.3` (according to the documentation) and the documentation is incorrect throughout versions `6.3`, `6.4`, `7.0`, `7.1` and `7.2`. I'm not sure how to distribute this PR to all other branches - should I create separate PRs for each? Commits ------- 468a9ac [Mailer] Fixed and clarified custom Content-ID feature documentation
2 parents 0742e26 + 468a9ac commit 90140b4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mailer.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,16 +682,18 @@ images inside the HTML contents::
682682
->html('... <div background="cid:footer-signature"> ... </div> ...')
683683
;
684684

685+
The actual Content-ID value present in the e-mail source will be randomly generated by Symfony.
686+
685687
You can also use the :method:`DataPart::setContentId() <Symfony\\Component\\Mime\\Part\\DataPart::setContentId>`
686688
method to define a custom Content-ID for the image and use it as its ``cid`` reference::
687689

688690
$part = new DataPart(new File('/path/to/images/signature.gif'));
689-
$part->setContentId('footer-signature');
691+
$part->setContentId('footer-signature@my-app');
690692

691693
$email = (new Email())
692694
// ...
693695
->addPart($part->asInline())
694-
->html('... <img src="cid:footer-signature"> ...')
696+
->html('... <img src="cid:footer-signature@my-app"> ...')
695697
;
696698

697699
.. versionadded:: 6.1

0 commit comments

Comments
 (0)