[12.x] Fix embedded image Content-ID inconsistency in cloned emails #57726
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
DataPartconstructor inembed()andembedData()methods. The second parameter ofDataPartisfilename, not Content-ID.DataPartgenerates 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.