Skip to content
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

Invoice Sales Email not send #13466

Closed
LordHansolo opened this issue Feb 2, 2018 · 30 comments
Closed

Invoice Sales Email not send #13466

LordHansolo opened this issue Feb 2, 2018 · 30 comments
Labels
Component: Sales 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: Format is valid Gate 1 Passed. Automatic verification of issue format passed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done

Comments

@LordHansolo
Copy link

Preconditions

  1. Magento 2.2.2
  2. OS: Ubuntu 16.04
  3. Mysql version 5.7.21
  4. PHP version 7.0.22

Steps to reproduce

  1. Set up "Stores -> Settings -> Configuration -> Sales -> Sales Emails -> Invoice -> Enabled -> Yes"
  2. Configure PayPal "Stores -> Settings -> Configuration -> Sales -> Payment Methods -> PayPal -> Payment Action -> Sale"
  3. Make order and pay with PayPal.

Expected result

  1. Order Created
  2. Email with order information send.
  3. Invoice Created
  4. Email with invoice information send

Actual result

  1. Order Created <- ok
  2. Email with order information send. <- ok
  3. Invoice Created <- ok
  4. Email with invoice information is not send <- wrong

Overview docs http://docs.magento.com/m2/ce/user_guide/configuration/sales/sales-emails.html
Since sales emails for invoice is enabled Magento should sends a transactional email for each invoice generated.

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

@LordHansolo Asynchronous sending enabled? then it should run through cron.
You can refer https://magento.stackexchange.com/questions/198779/how-does-asynchronous-email-sending-works-in-magento-2

@LordHansolo
Copy link
Author

LordHansolo commented Feb 2, 2018

@sivajik34 Thank you for response.
Now I understand that config is only for "Asynchronous sending".
I expected that email with invoice is send always after invoice is generated regardless "Asynchronous sending" configuration.
I expected that especially when you pay via PayPal with "Payment Action" set on "Sale". Invoice is generated automatically with status Paid if everything is correct but email is not send.

@sivajik34
Copy link
Contributor

if Asynchronous sending disabled:
then flow
step1:
magento/module-sales/etc/events.xml:
<observer name="sales_send_order_invoice_emails" instance="SalesOrderInvoiceSendEmailsObserver" />
step2:
magento/module-sales/etc/di.xml:

 <virtualType name="SalesOrderInvoiceSendEmailsObserver" type="Magento\Sales\Observer\Virtual\SendEmails">
        <arguments>
            <argument name="emailSenderHandler" xsi:type="object">SalesOrderInvoiceSendEmails</argument>
        </arguments>
    </virtualType>
 <virtualType name="SalesOrderInvoiceSendEmails" type="Magento\Sales\Model\EmailSenderHandler">
        <arguments>
            <argument name="emailSender" xsi:type="object">Magento\Sales\Model\Order\Email\Sender\InvoiceSender</argument>
            <argument name="entityResource" xsi:type="object">Magento\Sales\Model\ResourceModel\Order\Invoice</argument>
            <argument name="entityCollection" xsi:type="object" shared="false">Magento\Sales\Model\ResourceModel\Order\Invoice\Collection</argument>
        </arguments>
    </virtualType>

step 3:
Magento\Sales\Observer\Virtual\SendEmails:

 /**
     * Handles asynchronous email sending during corresponding
     * cron job.
     *
     * Also method is used in the next events:
     *
     * - config_data_sales_email_general_async_sending_disabled
     *
     * Works only if asynchronous email sending is enabled
     * in global settings.
     *
     * @param \Magento\Framework\Event\Observer $observer
     * @return void
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $this->emailSenderHandler->sendEmails();
    }

here emailSenderHandler -> Magento\Sales\Model\EmailSenderHandler

/**
    * Handles asynchronous email sending
    * @return void
    */
   public function sendEmails()
   {
       if ($this->globalConfig->getValue('sales_email/general/async_sending')) {
           $this->entityCollection->addFieldToFilter('send_email', ['eq' => 1]);
           $this->entityCollection->addFieldToFilter('email_sent', ['null' => true]);

           /** @var \Magento\Sales\Model\AbstractModel $item */
           foreach ($this->entityCollection->getItems() as $item) {
               if ($this->emailSender->send($item, true)) {
                   $this->entityResource->save(
                       $item->setEmailSent(true)
                   );
               }
           }
       }
   }

even if you disable async finally its calling async code. still, i have some confusion implementation of this.

@LordHansolo
Copy link
Author

LordHansolo commented Feb 2, 2018

@sivajik34 One more time thank you.
I updated my previous comment.
Now it is clear, that invoice email is not send if "Asynchronous sending" is disabled.
During read configuration files, especially magento/module-sales/etc/events.xml with fragment below:
<event name="config_data_sales_email_general_async_sending_disabled"> ... </event>
I had hape that emails should be send but after fully code read my hope has gone out ;)

@LucScu
Copy link

LucScu commented Apr 9, 2018

some progress on this issue?

@ghost ghost self-assigned this Jul 31, 2018
@ghost ghost added 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 Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Component: Sales labels Jul 31, 2018
@ghost
Copy link

ghost commented Jul 31, 2018

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

@ghost ghost added the Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release label Jul 31, 2018
@ghost ghost removed their assignment Jul 31, 2018
@nntoan
Copy link
Contributor

nntoan commented Sep 16, 2018

@engcom-backlog-nazar Any progress so far?

@avaldi
Copy link

avaldi commented Oct 11, 2018

Guys, any update on this?

@Darkbelg
Copy link

We are experiencing this issue. Is there any timeframe when this is going to be fixed ?

@deloenzien
Copy link

will this be solved in 2.3.1?

@fabrice-dresscodes
Copy link

Hello. Any progress or fix ?

@deloenzien
Copy link

Enable Asynchronous sending. Then cron takes care of sending e-mails.
This works for me.

@fabrice-dresscodes
Copy link

In which version of Magento. On 2.2.3 with asynchronous sending it doest not work for me.

When I invoice manually and check Send Mail it works.

@nadeefit6
Copy link

The issue can be reproduced in 2.2.7 as well.
Other than "Asynchronous sending" Invoice email sending is not developed in Paypal module.

@nadeefit6 nadeefit6 self-assigned this Mar 26, 2019
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Mar 26, 2019

Hi @nadeefit6. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

nadeefit6 added a commit to nadeefit6/magento2 that referenced this issue Mar 26, 2019
 - Invoice email through paypal express
nadeefit6 added a commit to nadeefit6/magento2 that referenced this issue Mar 26, 2019
 - Invoice email through paypal express
@ghost ghost removed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Sep 2, 2020
@ghost ghost assigned ilnytskyi Sep 2, 2020
@ghost ghost added this to PR In Progress in Community Backlog Sep 2, 2020
@sidolov sidolov added this to Ready for Grooming in Low Priority Backlog Sep 3, 2020
@m2-community-project m2-community-project bot moved this from Ready for Grooming to Pull Request In Progress in Low Priority Backlog Sep 3, 2020
@m2-community-project m2-community-project bot added Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Sep 3, 2020
@sidolov sidolov added this to Ready for Grooming in Low Priority Backlog Sep 24, 2020
@m2-community-project m2-community-project bot moved this from Ready for Grooming to Pull Request In Progress in Low Priority Backlog Sep 24, 2020
@m2-community-project m2-community-project bot added Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Sep 24, 2020
@sidolov sidolov added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Oct 20, 2020
@ghost ghost added this to Pull Request In Progress in High Priority Backlog Oct 20, 2020
@ghost ghost removed this from PR In Progress in Community Backlog Oct 20, 2020
@ghost ghost removed this from Pull Request In Progress in Low Priority Backlog Oct 20, 2020
@ghost ghost added Progress: PR in progress and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Oct 20, 2020
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Ready for Development in High Priority Backlog Jan 8, 2021
@engcom-Charlie
Copy link
Contributor

engcom-Charlie commented Jan 8, 2021

Hello, @LordHansololooks like the issue has already been fixed on the latest 2.4-develop please see #27739 (comment).
Please feel free to comment, reopen, or create a new ticket if you are still facing this issue on the latest 2.4-develop branch. Thank you for your collaboration.

Thanks for your report!

@magento-engcom-team
Copy link
Contributor

Unfortunately, we are archiving this ticket now as it did not get much attention from both Magento Community and Core developers for an extended period. This is done in an effort to create a quality, community-driven backlog which will allow us to allocate the required attention more easily.

Please feel free to comment or reopen according to the Issue reporting guidelines
the ticket if you are still facing this issue on the latest 2.x-develop branch. Thank you for collaboration.

@drinkingsouls
Copy link

I also have an issue with Magento Invoice emails not being sent automatically. Manual sends fine. Asynchronous is enabled but stll doesn't send. Other emails send fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Sales 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: Format is valid Gate 1 Passed. Automatic verification of issue format passed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done
Projects
Development

Successfully merging a pull request may close this issue.