8000 [Mailer][Postmark] Inline images with content ID not referenced correctly · Issue #60097 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Mailer][Postmark] Inline images with content ID not referenced correctly #60097

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

Closed
aleho opened this issue Mar 31, 2025 · 1 comment
Closed

Comments

@aleho
Copy link
Contributor
aleho commented Mar 31, 2025

Symfony version(s) affected

6.4

Description

The fix #59836 for bug #59819 broke attaching inline images to emails from Twig if that part has a CID.

Before the change an attachment would look like this:

--mk3-d5519ae4f67c4b77adc67d13c67652b0
Content-Type: image/png; name="@assets/img/logo-email.png"
Content-Transfer-Encoding: base64
Content-Id: <@assets/img/logo-email.png>
Content-Disposition: inline; filename="@assets/img/logo-email.png"

Now when the same image is attached this is the resulting source:

--mk3-5ae7974fd5db4896b88f552f84d16213
Content-Type: image/png; name="@assets/img/logo-email.png"
Content-Transfer-Encoding: base64
Content-Id: <2cbd223df91ad9f20e2ac4c6a86ad072@symfony>
Content-Disposition: inline; filename="@assets/img/logo-email.png"

It might seem correct to set a CID, but this is only works for attachments if they don't have a content ID. "ad-hoc" attachments using Twig broke here if that part (for whatever reason) has a content ID which will always differ from the filepath.

The problem is that the resulting markup is still referencing the "old" CID:

<img src=3D"cid:@assets/img/email-bg.png" ….

I guess this might have been the reason why the filename was used for ContentID instead of actually using DataPart::getContentId().

How to reproduce

Attach an image part with a CID to an email using email.image in Twig. Send templated email with Postmark API.

Possible Solution

A valid fix (apart from reverting the PR) might be updating WrappedTemplatedEmail::image to actually use the CID of the image part it attaches. I tested this with local Maildev and a real Postmark API transport, but there might be problems I'm not thinking about. This would also "improve" image tags references in email which currently are often referenced with a Twig part that of course doesn't exist anywhere and might be misleading. randomchars@symfony would be much better in my opinion.

Additional Context

No response

@aleho aleho added the Bug label Mar 31, 2025
@aleho aleho changed the title [Mailer][Postmark] Inline images not referenced correct 7ED5 ly [Mailer][Postmark] Inline images with CID not referenced correctly Mar 31, 2025
@aleho aleho changed the title [Mailer][Postmark] Inline images with CID not referenced correctly [Mailer][Postmark] Inline images with content ID not referenced correctly Mar 31, 2025
@aleho
Copy link
Contributor Author
aleho commented Apr 7, 2025

I'm not sure this is a bug any more, and I'm having a hard time reproducing it myself with a clean setup.

Maybe gremlins change my HTML, who knows?

@aleho aleho closed this as completed Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0