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.
@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
@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.
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.
@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 ;)
some progress on this issue?
Hi @LordHansolo thank you for your report.
We've acknowledged the issue and added to our backlog.
@engcom-backlog-nazar Any progress so far?
Guys, any update on this?
We are experiencing this issue. Is there any timeframe when this is going to be fixed ?
will this be solved in 2.3.1?
Hello. Any progress or fix ?
Enable Asynchronous sending. Then cron takes care of sending e-mails.
This works for me.
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.
The issue can be reproduced in 2.2.7 as well.
Other than "Asynchronous sending" Invoice email sending is not developed in Paypal module.
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:
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
branchDetails
- 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_!
[x] 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.
Hey Guys,
This extension should solve the problem.
https://redchamps.com/invoice-email-magento-2-extension.html
I have a Magento 2.3.1 installation and this issue seems like its still present
Hi guys,
I know this still in progress but, did you solved it by doing something?
I have tried to enable the Async sending but still not receiving the Invoice mail.
Thanks a lot
Hi guys,
I fixed this bug.
https://github.com/py4762013/Magento_AutoInvoiceEmail
Hi guys,
I fixed this bug.
https://github.com/py4762013/Magento_AutoInvoiceEmail
I have tried your code, but it is not working. However, I do not know how to debug your code either.
Edit: Just to remind everyone, both enabling or disabling async are not working, the invoice won't be sent even if you enable it.
I don't know what is causing the actual problem but I have a workaround.
Invoices seem to be sent OK if the customer has an account. It looks like the New Invoice Guest Template is faulty.
Go to Marketing> Email Templates>Add New Template
Load default template from New Invoice.
Make any changes and save as New Invoice Guest Custom.
Go to Stores>Configuration>Sales>Sales Emails>
Under Invoice > Invoice Email Template for Guest. change this to the new template you saved.
Flush cache
@deckside I have done it since the creation of the web. I have my own template with css. I can't solve it like that :S
I have made a workaround using API and creating my own script.
Tried the work around suggested above by @py4762013 also tried new templates but no luck :(
Does not work for guest or logged in customer.
This might be impacting other Payment Methods I know it does for PoliPay and Payment Express..
Hi @LordHansolo.
Thank you for your report and collaboration!
The issue was fixed by Magento team. The fix was delivered into magento/magento2:2.3-develop
branch(es).
Related commit(s):
The fix will be available with the upcoming 2.3.4
release.
@magento-engcom-team
Will the above commits work to patch this on Magento <2.3.4 such as 2.3.0?
What about shipment tracking emails?
Edit:
Okay the paid module from rav-redchamps resolves this for invoice emails, but not for shipment tracking emails. It's quite a simple work-around well done.
This module will make your invoice emails work
https://webpanda-solutions.com/auto-invoice-shipment.html
It works with offline payment methods, online payment methods with action Authorize also with Authorize and Capture.
@magento-engcom-team @StasKozar @viktym
the code from, supposed to be released in 2.3.4
https://github.com/magento/magento2/commit/5ccd367ebc628b588a77cb2032faeabd6005b039
and actual 2.3.4 and 2.4-develop is a bit different
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Quote/Observer/SubmitObserver.php
so as we understand now the customer will always have 2 emails after order placing ?
btw what to do if we do not want to automatically sent an invoice email after order placing ?
The issue was related to PayPal module. So the PayPal module is responsible for sending its invoice. Why did you decide that every time there is an invoice in magento it should be sent???
Most helpful comment
@magento-engcom-team @StasKozar @viktym
the code from, supposed to be released in 2.3.4
https://github.com/magento/magento2/commit/5ccd367ebc628b588a77cb2032faeabd6005b039
and actual 2.3.4 and 2.4-develop is a bit different
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Quote/Observer/SubmitObserver.php
so as we understand now the customer will always have 2 emails after order placing ?
btw what to do if we do not want to automatically sent an invoice email after order placing ?
The issue was related to PayPal module. So the PayPal module is responsible for sending its invoice. Why did you decide that every time there is an invoice in magento it should be sent???