Skip to content

Commit 19c550d

Browse files
committed
bug symfony#38529 [Mailer] Fix mailjet image embedding (Sandldan)
This PR was merged into the 5.x branch. Discussion ---------- [Mailer] Fix mailjet image embedding Filename is not enough to embed the image through cid, ContentID field has to be set with the cid identifier used in the HTMLPart | Q | A | ------------- | --- | Branch? | 5.1 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | none <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | not needed <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too.) - Features and deprecations must be submitted against branch 5.x. --> Hello! While switching from `Mandrill` to `Mailjet` I noticed that embedding images was not working properly, the `Content-ID` mime is not set properly without setting the `ContentID` key. With this change things will work as described in the [symfony documentation](https://symfony.com/doc/current/mailer.html#embedding-images) [Mailjet reference](https://dev.mailjet.com/email/guides/send-api-v31/#send-with-attached-files) Commits ------- 7ab772e [Mailer] Fix mailjet image embedding
2 parents 444626b + 7ab772e commit 19c550d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/Symfony/Component/Mailer/Bridge/Mailjet/Transport/MailjetApiTransport.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ private function prepareAttachments(Email $email, ?string $html): array
158158
'Base64Content' => $attachment->bodyToString(),
159159
];
160160
if ('inline' === $headers->getHeaderBody('Content-Disposition')) {
161+
$formattedAttachment['ContentID'] = $headers->getHeaderParameter('Content-Disposition', 'name');
161162
$inlines[] = $formattedAttachment;
162163
} else {
163164
$attachments[] = $formattedAttachment;

0 commit comments

Comments
 (0)