Skip to content

Commit 329e8c8

Browse files
committed
minor #18817 [Mailer] Embedding images support custom cid (alamirault)
This PR was merged into the 6.3 branch. Discussion ---------- [Mailer] Embedding images support custom cid Fix #17703 It was complicated to me to understand well PR and use case, as it's very specific and can be considered as a bugfix, but it's was e feature. Example of use case: We send an Email with `Parts` and html with cid (human friendly name is replaced by generated cid). We want to forward this email, so we keep the same html (with generated cid) and `Parts` are rebuild with generated cid (setContentId). Now it works (cid are kept), but before it was ko Commits ------- cee2e96 Embedding images support custom cid
2 parents de325d6 + cee2e96 commit 329e8c8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

mailer.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,27 @@ images inside the HTML contents::
616616
->html('... <div background="cid:footer-signature"> ... </div> ...')
617617
;
618618

619+
You can also use :method:`DataPart::setContentId() <Symfony\\Component\\Mime\\Part\\DataPart::setContentId>` method to
620+
define value and use it as ``cid`` reference::
621+
622+
$part = new DataPart(new File('/path/to/images/signature.gif'));
623+
$part->setContentId('footer-signature');
624+
625+
$email = (new Email())
626+
// ...
627+
->addPart($part->asInline())
628+
->html('... <img src="cid:footer-signature"> ...')
629+
;
630+
619631
.. versionadded:: 6.1
620632

621633
The support of embedded images as HTML backgrounds was introduced in Symfony
622634
6.1.
623635

636+
.. versionadded:: 6.3
637+
638+
The support of custom ``cid`` for embedded images was introduced in Symfony 6.3.
639+
624640
.. _mailer-configure-email-globally:
625641

626642
Configuring Emails Globally

0 commit comments

Comments
 (0)