Skip to content

Order Email Sender #13769

@pawcioma

Description

@pawcioma

Probably I found wrong logical in "\Magento\Sales\Model\Order\Email\Sender::checkAndSend" because you catch Exception and then you return true. In database will be information about send_email and email_sent as true, but email can not be sent.

Original code:
`protected function checkAndSend(Order $order)
{
$this->identityContainer->setStore($order->getStore());
if (!$this->identityContainer->isEnabled()) {
return false;
}
$this->prepareTemplate($order);

    /** @var SenderBuilder $sender */
    $sender = $this->getSender();

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

    return true;

}`

For my opinion should be:
`protected function checkAndSend(Order $order)
{
$this->identityContainer->setStore($order->getStore());

    if (!$this->identityContainer->isEnabled()) {
        return false;
    }

    $this->prepareTemplate($order);

    /** @var SenderBuilder $sender */
    $sender = $this->getSender();

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

        return false;
    }

    return true;
}`

Metadata

Metadata

Assignees

Labels

Fixed in 2.1.xThe issue has been fixed in 2.1 release lineFixed 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 not validGate 1 Failed. Automatic verification of issue format is failedIssue: 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 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions