magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Mollie webhook retrying after getting 500 due to spam rejection SMTP

Open erwinschaap opened this issue 9 months ago • 4 comments

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

  • Magento Version number(eg 2.3.5): 2.4.6-p3
  • Open source/Enterprise/B2b: Open source
  • Mollie version number (Check configuration): 2.34.0

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

erwinschaap avatar Apr 29 '24 07:04 erwinschaap

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!

Frank-Magmodules avatar May 01 '24 06:05 Frank-Magmodules

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

erwinschaap avatar May 01 '24 07:05 erwinschaap

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

Frank-Magmodules avatar May 01 '24 07:05 Frank-Magmodules

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.

Frank-Magmodules avatar May 02 '24 08:05 Frank-Magmodules

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

erwinschaap avatar May 10 '24 14:05 erwinschaap

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.

Frank-Magmodules avatar May 13 '24 07:05 Frank-Magmodules

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

  • We are using the Order API for most payment methods
  • The problem with 500's in the webhook is only when having SMTP issues (SPAM rejected, receipt policy rejections)
  • In the Mollie logs there are no issues, we are receiving always success results: success: {"success":true,"status":"paid","order_id":"x","type":"webhook"} [] []
  • In the Mollie dashboard there are only 500's received somehow
  • Because of the 500's, there are periodically retries to get a success result
  • In Magento all went well and because of that all orders status are resetting everytime the webhook is called

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

erwinschaap avatar May 13 '24 08:05 erwinschaap

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 avatar May 21 '24 18:05 Frank-Magmodules

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

Frank-Magmodules avatar May 30 '24 13:05 Frank-Magmodules

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

erwinschaap avatar Jun 03 '24 08:06 erwinschaap

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.

Frank-Magmodules avatar Jun 03 '24 13:06 Frank-Magmodules