Skip to content

Failure of "Send Order Email Copy" spams customers, every minute, forever. #17152

@lingwooc

Description

@lingwooc

Magento 2.2.5 resends emails to customers if the "Send Order Email Copy" feature fails. This is due to a naive check in Magento\Sales\Model\Order\Email\Sender.php . It was PR #14051 to fix #13769 that did it.

It doesn't discriminate between a failure in the email copy (probably to a company address) and an email to a customer. If the copy fails repeatedly (I've literally never had this feature work) then it will spam your customers once a minute for ever. This is super dumb.

This is the code:

        try {
            $sender->send();
            $sender->sendCopyTo();
        } catch (\Exception $e) {
            $this->logger->error($e->getMessage());

            return false;
        }

        return true;

It should probably be:

        try {
            $sender->send();
        } catch (\Exception $e) {
                $this->logger->error($e->getMessage());
            return false;
        }
        try {
            $sender->sendCopyTo();
        } catch (\Exception $e) {
            $this->logger->error($e->getMessage());
        }
        return true;

Although really its a great demonstration of why using a boolean to determine an error state isn't a great idea.

Preconditions

Magento 2.2.5
Broken "Send Order Email Copy"
Asyncronous email sending

Steps to reproduce

  1. Set magento2 to send a separate email copy of an order
  2. Turn on "Asyncronous email sending"
  3. Make an order

Expected result

  1. Set magento2 to send a separate email copy of an order
  2. Turn on "Asyncronous email sending"
  3. Make an order
    4 Don't spam customers

Actual result

  1. Set magento2 to send a seperate email copy of an order
  2. Turn on "Asyncronous email sending"
  3. Make an order
  4. Spam your customers

Metadata

Metadata

Assignees

Labels

Component: SalesEvent: mm18hrFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasehelp wanted

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions