Skip to content

[Mailer] Fixed and clarified custom Content-ID feature documentation #19946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mailer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -658,16 +658,18 @@ images inside the HTML contents::
->html('... <div background="cid:footer-signature"> ... </div> ...')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we replace the ID in this code example too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That cid relates to the filename prop of the DataPart and symfony will replace it with a generated hash in the source. The example is correct.

;

The actual Content-ID value present in the e-mail source will be randomly generated by Symfony.

You can also use the :method:`DataPart::setContentId() <Symfony\\Component\\Mime\\Part\\DataPart::setContentId>`
method to define a custom Content-ID for the image and use it as its ``cid`` reference::

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

$email = (new Email())
// ...
->addPart($part->asInline())
->html('... <img src="cid:footer-signature"> ...')
->html('... <img src="cid:footer-signature@my-app"> ...')
;

.. versionadded:: 6.1
Expand Down
Loading