magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Sometimes, after an order is placed, 'The order confirmation email is not sent'.

Open PierAlex opened this issue 9 years ago • 18 comments

Preconditions

  1. Magento 2.1.2
  2. Plesk Onyx 17.0.17
  3. Ubuntu 14.04.5 LTS‬
  4. PHP 7.0.19
  5. MySql 5.7.18

Steps to reproduce

  1. Insert valid email address(es) in Stores->Configuration->Sales->Sales emails->Send Order Email Copy To.
  2. Place an order

Expected result

  1. Send Confirmation email to the customer
  2. Send copy of the confirmation email to address(es) specified as above.

Actual result

  1. SOMETIMES, apparently without any ability for the customer to specify that he doens't want to receive the order confirmation email, order confirmation emails are not sent. Not sent to the customer and not sent to addresses specified as above.

In the database, in sales_order table, 'email_sent', usually = 1, is null. Also the field 'send_email', usually = 1, is null.

Why this field is null? May it be responsible for the 'non-sending' confirmation?

PierAlex avatar May 23 '17 10:05 PierAlex

+1

poochie2 avatar Jun 21 '17 08:06 poochie2

Problem is still happening in Magento 2.1.7.

Field 'email_sent' is null. Field 'send_email' Always = 1.

So it means that checkAndSend($order) return false in file 'Magento\Sales\Model\Order\Email\Sender\OrderSender.php'

public function send(Order $order, $forceSyncMode = false)
{
    $order->setSendEmail(true);

    if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
        if ($this->checkAndSend($order)) {
            $order->setEmailSent(true);
            $this->orderResource->saveAttribute($order, ['send_email', 'email_sent']);
            return true;
        }
    }

    $this->orderResource->saveAttribute($order, 'send_email');

    return false;
}

and that $this->identityContainer->isEnabled() return false in Magento\Sales\Model\Order\Email\Sender.php

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;
}

What is exactely $this->identityContainer->isEnabled() and how can iti be null 'sometimes'?

PierAlex avatar Jun 27 '17 06:06 PierAlex

As a workaround I override Sender.php commenting this: if (!$this->identityContainer->isEnabled()) { return false; }

in fact, in my configuration, email order confirmation has always to be sent; I cannot figure out in wich conditions (identityContainer->isEnabled()???) the email confirmation has not to be sent when an order is correctly placed.

Wainting for info from Magento people.

PierAlex avatar Jun 27 '17 13:06 PierAlex

@PierAlex, thank you for your report. We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue. We tested the issue on 2.3.0-dev, 2.2.0, 2.1.9

magento-engcom-team avatar Oct 11 '17 10:10 magento-engcom-team

@PierAlex did you find a cause for the problem? I'm facing the same... Your work around makes al mails sendig, i only want to send the order conformation

Jilco avatar Dec 11 '17 08:12 Jilco

I'm facing the same issue on Magento EE 2.0.17

SukeshiniR avatar Dec 11 '17 08:12 SukeshiniR

@Jilco, no sorry.

PierAlex avatar Dec 11 '17 12:12 PierAlex

Still getting issue in Magento 2.1.10. All other emails are reeving , but no order confirmation email. Tried with Asynchronous true and false, but no luck :(

titechnologies avatar Feb 01 '18 12:02 titechnologies

Got the same issue on v2.2.3. But turned out it was not Magento issue, but payment gateway implementation.

Magento sends order confirmation email on sales_model_service_quote_submit_success event in Magento\Quote\Observer\Webapi\SubmitObserver but payment gateway implementation in my case redirected customer from checkout page through javascript and then directly to success page, so the event above was omitted.

gendosua avatar Apr 09 '18 06:04 gendosua

In my totals there are half eurocents, eg. 12,955. The payment module (Mollie) didn't proces that kind of amount properly


Van: Radu CIOCOIU [email protected] Verzonden: maandag 5 november 2018 10:48 Aan: magento/magento2 CC: Jilco; Mention Onderwerp: Re: [magento/magento2] Sometimes, after an order is placed, 'The order confirmation email is not sent'. (#9737)

Hi @Gendos-uahttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FGendos-ua&data=02%7C01%7C%7C548e828eac12443e5ca608d64303e681%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636770081354932348&sdata=BuHJT7tr44Vp9eRDYJS2e611%2FGQrpu0T5eMZJa8aRvA%3D&reserved=0 What was the solution in your case?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmagento%2Fmagento2%2Fissues%2F9737%23issuecomment-435814620&data=02%7C01%7C%7C548e828eac12443e5ca608d64303e681%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636770081354932348&sdata=sX60NgchGYg%2FcMwClXV2amcuo7yUDM5mjD%2FHU%2BY%2FM9k%3D&reserved=0, or mute the threadhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAWoMGjb1ctcQPoMBbylxd2wOk6_5HFT8ks5usAmGgaJpZM4NjeUp&data=02%7C01%7C%7C548e828eac12443e5ca608d64303e681%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636770081354932348&sdata=HCnFVq21LlWRQrTbQiHQN1347%2F9xUe5MpHglqVme7VI%3D&reserved=0.

[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virusvrij. www.avast.comhttps://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail

Jilco avatar Nov 05 '18 11:11 Jilco

Getting same issue In Magento 2.2.5, Some orders email are not send automatically - I have to send it manually. what is the issue ?

jigar48 avatar Dec 13 '18 17:12 jigar48

We also have a client that has this issue. Most of the time the email does not send but it does send some of the time. Magento 2.2.7

ghost avatar Dec 27 '18 16:12 ghost

The transportbuilderbystore class has already been deprecated in 2.3 and soon will be in 2.2. This will also work in Magento 2.2.7

https://magento.stackexchange.com/a/257215/68619

pratikhmehta avatar Jan 09 '19 09:01 pratikhmehta

any solution? i have this issue in magento 2.3.1

taoufiqaitali avatar May 10 '19 10:05 taoufiqaitali

We are using payu plugin in magento 2.3.3 the movement the it goes to the payment gateway page the order confirmation mail is sent out

We need to know how we can get this working to send mail only after payment confirmation

I se that the above solution working for lower version but not for 2.3.3 do you have any support on this ? http://www.tecsilk.com

techd7 avatar Jan 02 '20 18:01 techd7

I have smae issue sometimes. any fix

DiaaSaada avatar May 11 '20 10:05 DiaaSaada

I have the same problem with Magento 2.3.5

@magento-engcom-team you should reopen it

mariospas avatar Oct 10 '20 20:10 mariospas

any update? I have the same problem on 2.4.6-p2

khoinguyen-incepit avatar Dec 10 '24 10:12 khoinguyen-incepit