Skip to content

Sales Emails Async Sending issue #16165

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
mihaifaget opened this issue Jun 15, 2018 · 5 comments
Closed

Sales Emails Async Sending issue #16165

mihaifaget opened this issue Jun 15, 2018 · 5 comments
Labels
Component: Cron Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release

Comments

@mihaifaget
Copy link

mihaifaget commented Jun 15, 2018

Working on a clean magento 2.2.4.

Preconditions

Magento Version 2.2.4

Steps to reproduce

Enable Async sending from Stores->Configuration->Sales->Sales Emails->Asynchronous sending. Create 2(or more) orders. Run cron(twice if you don't already have sales_send_order_emails scheduled)

Expected result

An order email should be sent for each order in the queue.

Actual result

Only 1 email is sent for the first order in queue and marks all other orders as sent (email_sent in sales_order table)

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jun 15, 2018
@gwharton
Copy link
Contributor

I suspect that it might be this commit that broke this in 2.2.4 by @RomaKis, although further checks should be made to be sure.

f2bfdd9

There were changes made to the email senders to fix issue #11740.

An unintended consequence of this commit is that if multiple emails are sent under the same process, i.e a cron process sending two or more emails at the same time, then the first email will succeed and the send on the remaining emails will fail with an exception.

The exception is triggered here

$this->message->setFrom($result['email'], $result['name']);

After this change, new in 2.2.4, the message object is now static, and not cleared after each email is sent. The exception is triggered as the from header is being set on a message object that still has the from header set from the 1st email.

I have several modules that provide massActions to send emails out, e.g resend order email, resend invoice email. These also fail in the same way on 2.2.4 and just send out the first email, if multiple emails are triggered. Reverting the above commit, fixes the issue for me.

If you don't need the fix from #11740 then you can workaround this issue by reverting the above commit.

@gwharton
Copy link
Contributor

gwharton commented Jul 5, 2018

PR #16461 is awaiting review and will fix this issue.

@ghost ghost self-assigned this Jul 31, 2018
@ghost ghost added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Component: Cron Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Fixed in 2.3.x The issue has been fixed in 2.3 release line labels Jul 31, 2018
@ghost
Copy link

ghost commented Jul 31, 2018

@mihaifaget, thank you for your report.
We've acknowledged the issue and added to our backlog.

@gwharton
Copy link
Contributor

Fixed in 2.2-develop
9a7c9e5#diff-dfb3ee5a7f863458afea75f5524cd2e5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Cron Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release
Projects
None yet
Development

No branches or pull requests

3 participants