Skip to content

Conversation

@yinheli
Copy link

@yinheli yinheli commented Nov 10, 2025

Problem

When using failover mailer configurations (e.g., Mailgun → AWS SES), embedded
images in emails fail to display after the email object is cloned for retry.

The issue occurs because the Content-ID referenced in HTML (<img src="cid:...">)
and the Content-ID in the MIME attachment become inconsistent after cloning.

Root Cause

Incorrect usage of the DataPart constructor in embed() and embedData() methods. The second parameter of DataPart is filename, not Content-ID.
DataPart generates its own Content-ID automatically.

Reproduction

I've isolated a unit test to simulate the failover clone scenario. To reproduce the issue, please check out commit 23b3783.

Apology and Context

I apologize for not including a reproduction test in my previous PR #57606. This PR adds a failing test case and the corresponding fix.
Thank you for the patience and thorough review.

@yinheli yinheli force-pushed the bugfix/embed-datapart-api-misuse branch from c1a5c50 to d30da28 Compare November 10, 2025 06:05
@yinheli yinheli force-pushed the bugfix/embed-datapart-api-misuse branch from d30da28 to 2965a3d Compare November 10, 2025 06:34
@yinheli yinheli changed the title Fix embedded image Content-ID inconsistency in cloned emails [12.x] Fix embedded image Content-ID inconsistency in cloned emails Nov 10, 2025
@taylorotwell
Copy link
Member

taylorotwell commented Nov 10, 2025

I feel like we're changing a lot of code and logic just to fix what I would imagine is a much simpler bug? 👀 What is the minimum possible change to fix the issue?

@yinheli
Copy link
Author

yinheli commented Nov 10, 2025

While fixing the misuse of the DataPart API, I found that the tests also needed adjustments. I thought it would be best to fix everything properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants