-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
email attachments break. during the failover retries due to state contamination #57474
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
Comments
Can you create a small example application that allows to reproduce your issue? |
sorry sir. i'm try to learn the symfony mailer and spend full day to write this demo. this demo only to show the attachement object is changed by the vendor/symfony/mailer/Transport/AbstractTransport.php send function. in this class send function here is composer version symfony/mailer 6.4.9 my local php version PHP 8.3.6 (cli) (built: Apr 10 2024 14:21:20) (NTS) please add an nas.png on the same folder the code
here is the output result,please note the comment like this prefix //--------------
email source error demo, the img src is wrong of attachment filename but not content-id
|
I am sorry, but without being able to reproduce the issue I am afraid there's not much we can do. That's why I am going to close. But we can always consider to reopen when we have more information. Thank you for understanding. |
I extend my heartfelt gratitude to the Symfony community for your unwavering dedication and perseverance.
Background
I was using the Laravel 10 mailer along with Symfony Mailer and encountered a bug related to failover functionality when the first mailer failed to send an email.
Failover Configuration
My failover setup is as follows:
Primary Mailer Driver: Mailgun
Secondary Mailer Driver: Amazon SES
Issue Description
When an email fails to send using Mailgun, the system attempts to send the email via Amazon SES. However, I discovered that emails sent through Amazon SES have broken image sources (src), causing the images to not display correctly in the emails.
Package version
symfony/mailer 6.4.8
symfony/mailgun-mailer 7.1.1
Try to Fix
I tried to fix the issue in the file located at vendor/symfony/mailer/Transport/RoundRobinTransport.php.
It worked when I made the following changes:
It seems that the $message attachments are a reference. The clone operation can't properly clone the attachments objects. Therefore, I changed it to use deep_copy to perform a deep clone for each send operation.
I also found that the Mailgun driver changes the attachments' CIDs.
Here is the modified section of the code:
My Local debug test
When I change the first driver to SMTP, it works well.
I do this before the FailoverTransport class, prior to the first send.
The attachment will have the wrong src path.
When I deep copy the message, everything worked well !!!
The Next Info for Reference
Here is the first email source.
It's normal and works well.
This will be used to compare with the second email source.
The image source is cid:V9J4rKBvmB and it will be replaced with cid:d3a788f4cbf3a6aab32dcacde69a2e34@symfony, resulting in the following output:
Here is the second image. The source is incorrect, so it can't be displayed.
The problematic image email source is here:
The image source is cid:L7HALxfBwi.
It should be updated to Content-ID cid:2eabc9240b3557c72ad65e92a60f7f57@symfony, but the result is still cid:L7HALxfBwi.
I found that this issue might be related to the Symfony\Component\Mailer\Transport\AbstractTransport class, specifically in the send function.
fake code for my test
I use Symfony Mailer in Laravel 10. Here is some example code (sorry for the demo code):
in the blade template of view
Additional Context
here is the dump of the $message by laravel dd() function, this content to show clone will not clone the #1826 object of $message->attachments
first email var $message dump, this is normal for compare the second wrong one
with broken image src of second email $message dump.
The text was updated successfully, but these errors were encountered: