mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
98 stars 49 forks source link

Mollie webhook retrying after getting 500 due to spam rejection SMTP #774

Closed erwinschaap closed 4 weeks ago

erwinschaap commented 2 months ago

Describe the bug When a user could not receive e-mails due to spam rejection, the mollie webhook calls gets 500 response code and will try every x time. The order is already invoiced with the first mollie webhook and the state is complete but every time the mollie webhook is triggered, the state is changing back to processing and mollie is capturing a new transaction

Used versions

To Reproduce Steps to reproduce the behavior: Mollie webhook getting 500 response due to an error in SMTP (e.g. spam rejection) A new transaction is captured and the state will be processing again (the order status for completed payments)

Expected behavior When a Mollie webhook is getting 500 response due to SMTP errors, the actual result should be a 200 OK for the Mollie workflow

Actual behavior It is returning a 500 internal server error

Frank-Magmodules commented 2 months ago

Hi There @erwinschaap,

Thank you for opening this issue. Could it be that you are using an external module for sending emails? We have tried various scenarios using Mailhog, but whenever an error occurs during email sending this is handled as expected. It is logged in both the exception.log and debug.log, but it is not shown to the end-user.

So I’m expecting that you are using some kind of external module that is causing this issue. Thanks!

erwinschaap commented 2 months ago

We are using Mageplaza SMTP (I think one of the most used module) https://github.com/mageplaza/magento-2-smtp

Frank-Magmodules commented 2 months ago

Ah ok, that's new information, thanks, will check it out @erwinschaap !

Frank-Magmodules commented 2 months ago

We investigated this once again, this time while using the Mageplaza SMTP module. We still seem to be unable to reproduce this. Mageplaza wraps its code around \Magento\Framework\Mail\TransportInterface::sendMessage, the same method that is being used by the native Magento implementation.

This method is for both the invoice and the order confirmation called by \Magento\Sales\Model\Order\Email\Sender::checkAndSend. That method tries to call the sendMessage method, but catches any exception (see code). When an exception occurs, this is logged and false is returned.

From the looks, this does not seem to be the cause of the problem that you are experiencing. What the exact cause then is, is hard to say. Are you able to share more information about what is going on and what errors you are experiencing? The email errors might popup in the logs, but do not seem to be related.

erwinschaap commented 1 month ago

We have updated all the modules and the issue still exists:

We are getting this error message in the logs: [2024-05-10T13:35:59.959010+00:00] main.ERROR: 5.2.0 x Spam Rejected (x= some id)

In the Mollie dashboard: Aanroepen webhook mislukt met statuscode 500 (Internal Server Error) 10 mei 2024 om 15:35

Exactly at the same time, first is because the SMTP service is getting Spam Rejected

Frank-Magmodules commented 1 month ago

Hi @erwinschaap,

That a 500 error is received is not good, but it’s hard to say what the exact cause is. As told before, the error is probably only logged but not shown. If it were shown on screen it would mean you would receive it also when creating shipments, invoices, or credit memos.

The error is probably hidden somewhere in your logs. It might be in the exception.log, debug.log or maybe even the PHP logs. But with the current information, it is very hard for us to help you any further.

erwinschaap commented 1 month ago

Hard to tackle this issue because there are no complementary logs in the exception, system, mollie logs:

We are having not enough information to really see what the problem is

Frank-Magmodules commented 1 month ago

Hi @erwinschaap, What’s the best way to proceed? I'm a bit lost at this point and can’t confidently conclude that this is a Mollie-related issue.

Frank-Magmodules commented 1 month ago

Hi @erwinschaap, could you let me know if there's still any action needed from our side? Thanks!

erwinschaap commented 4 weeks ago

Hi @Frank-Magmodules, we have enabled asynchronous email sending and a external SMTP service in Magento and the problems were fixed. There are some bad email services, like our previous email service which closes the connection unexpectedly after giving error spam rejection which causes uncaught exceptions in Laminas / Magaplaza SMTP. These problems ultimately influenced the way the Mollie plugin was developed. Perhaps you can develop it in such a way that the complete SMTP / email sending process does not affect Mollie, because that can still happen with some email services

Frank-Magmodules commented 4 weeks ago

Thank you once again for your response, @erwinschaap. We appreciate you confirming that this isn't an issue directly with the Mollie plugin. We believe this problem is more likely related to Magento itself rather than Mollie so therefore, we will be closing this issue now, but please feel free to reopen it if you have any further questions.