-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Sending multiple emails using the TransportBuilder class causes an Zend_Mail exception #14236
Comments
@david-kominek, please refer to the Community Forums or the Magento Stack Exchange site for advice or general discussion about this issue. The GitHub issue tracker is intended for Magento Core technical issues only. |
OK, so I'm just a little confused. The core team intended the TransportBuilder to be a single use class? The way that it currently is implemented, you can only use the TransportBuilder one time per request, no matter which class you inject it into. I thought the point of a "Builder" class was to be able to build multiple of something. |
@magento-engcom-team Are you sure it is appropriate to close this ticket? This seems to be a real issue. TransportBuilder should not be usable once per request only. For example, what about an extension creating 5 shipments for different orders and emailing them to customers, in "one request/execution" -- right now, using Magento\Sales\Model\Order\Email\Sender\ShipmentSender only the first of the five shipment emails would be sent, as after the first email, the above exception described by @david-kominek is stopping further emails from being sent. |
we have this problem too, first noticed after updating to 2.2.4. the TransportBuilder uses ObjectManager in reset() to create a "new"
once a mail was previously created, the object returned from the ObjectManager won't be a new, uniinitalized object and thus needs at least be reset properly. or get rid of the object manager stuff as everyone seems to preach nowadays. |
Having the same issue in 2.2.4. |
here's a core patch: bugfix--allow-more-than-one-email-being-sent.zip please refrain from commenting the ugliness of the patch - mostly due to the stupidity of this bug. I'm sure someone can come up with a nicer solution eventually by getting rid of this dependency injection/object manager mess introduced in 2.2.4. |
@heldchen Thanks. |
Is a bug indeed. Please re-open this issue. |
Same here... |
With Magento 2.2.4 the issue is in Magento\Framework\Mail\Template\TransportBuilderByStore, after setFrom not reset header from. Add this function:
and replace function setFromByStore with
|
@vlauria this will still instantiate a new message each time setFromByStore is called, and as such break multiple sending. check the zip I've added a few comments above for a working patch. |
@magento-engcom-team Could we have this re-reviewed or clarification added? It seems to be an actual issue with a fairly simple solution. |
@heldchen Magento into Magento\Framework\Mail\Template\TransportBuilder after send message instantiate a new message, like my fix. |
@david-kominek, thank you for your report. |
this is turning into a farce. the issue is reproducible with the steps in the initial ticket, but you probably ignored with 2 observer classes |
@heldchen, you can always create new issue with more obvious steps to reproduce. |
Just commenting in here since I've seen other related tickets around this. And there is also a pending PR for Magento2 which also seems to be around something very similar: #16461 Not sure if this causes the problem discussed in this thread? It seems related. |
The original issue is unrelated to the email issues introduced in 2.2.4. I've already got my solution for this issue which I mentioned in the original post. Since Magento team seems unable or unwilling to reproduce, hopefully this post will help those who come across the bug. It seems like it's not going to be resolved. |
@david-kominek Hopefully PR #16461 will be approved and merged soon. This will fix this issue, along with a host of other issues. It was the fix that was introduced to fix the original email problems, that introduced this new bug. PR #16461 is an alternative fix for the original email issue, but at the same time, does not introduce the new bug that causes the multiple email issues to occur. Hope this helps clarify. |
Fixed in 2.2-develop |
The 'fixes' provided in all of the respective tickets/commits linked within the current issue don't actually solve the issue or address the actual issue. I will briefly explain the issue that occurs as concise as possible. The main issue with a singleton is that any data that is set (for example the header in this case) is kept as long as a process is running. Example: Loop 1: Loop 2: Although the suggested fix from some of the commits in this issue A singleton is not supposed to be reinstantiated in the first place, the whole purpose of a singleton is to avoid new instances.
|
Hi @david-kominek. Thank you for your report.
The fix will be available with the upcoming 2.3.1 release. |
@gwharton @magento-engcom-team I'm confusing while it's still an issue after applied the patch on backport for my 2.2.7.
|
Someone from Magento will need to pick this up and look at what needs to be done moving forward. With respect to updating 2.2 going forward, Magento have stopped accepting fixes for the 2.2 release line now so would need to be pursued in the 2.3-develop line. |
Hi @engcom-Bravo. Thank you for working on this issue.
|
This issue is fixed on 2.3.x branches(i tried to reproduce on 2.3-develop). |
Preconditions
Steps to reproduce
Expected result
Actual result
The issue seems to be that the transport builder is not adequately cleaning up the $message variable after getting the transport. The solution is to overwrite the TransportBuilder class, and in the function getTransport() to the following:
Edit: I don't feel that @dimonovp really reviewed this ticket. Can we have it reopened and reviewed?
The text was updated successfully, but these errors were encountered: