Post by popular » Tue May 24, 2016 7:10 am

Hi All,

I've spent the better part of the day looking for a solution to a very annoying problem. If your OpenCart installation is configured to use an SMTP email server you've likely run into this too. Please note: disabling SMTP and using mail is not an option for me...

Server Details:
OpenCart Version 1.5.6.4
PHP 5.5.9-1ubuntu4.14
Apache/2.4.7 (Ubuntu)
SMTP Provider: MailGun

The Issue:
OpenCart attempts to send an order confirmation email via SMTP. If anything goes wrong during that process the order will hang and the user never gets to the success page. Furthermore you'll likely see duplicate orders because the user ends up clicking submit over and over not knowing that each order was actually successful.

This has been a really tricky one to troubleshoot because 99% of my orders go through without issue. I assume its the result of an SMTP connection lagging or failing but I can't be 100% sure. Each time it happens the error log shows the following entry:

Code: Select all

Error: Password not accepted from server! -  in checkout/system/library/mail.php
The Files:
(1) /checkout/catalog/model/checkout/order.php
(2) /checkout/system/library/mail.php

From what I've gathered order.php (1) is running the Confirm function which loads the mail class to send over the confirmation email. The mail class is expecting a 235 response code but doesn't get one for whatever reason and thus everything falls apart. See code below:

Code: Select all

if (substr($reply, 0, 3) != 235) {
 trigger_error('Error: Password not accepted from server!');
 exit();
}
I honestly don't really care that the confirmation email isn't sending < ~1% of the time. I thought about retrying etc but I think the best solution would be to simply fail gracefully. By that I mean, log the smtp email error and move on to confirming the order / loading the "checkout/success" page. Any ideas??

New member

Posts

Joined
Sun Jul 25, 2010 10:50 pm

Post by popular » Tue May 24, 2016 10:01 pm

Quick Update:

One thing I've tested is editing /checkout/system/library/mail.php and replacing all instances of

Code: Select all

exit(); 
with

Code: Select all

return;
That seems to allow order.php to keep executing even though the SMTP process failed but the customer still doesn't get redirected to the success page.

New member

Posts

Joined
Sun Jul 25, 2010 10:50 pm

Post by popular » Wed May 25, 2016 8:35 am

Okay so I managed to get SMTP to fail gracefully. Here's what you need to do if you want the accomplish the same thing (it's very possible there is a better way but this is all I could come up with)

Open up the file: /checkout/system/library/mail.php

Find all instances of:

Code: Select all

exit();
Comment those out and replace them with:

Code: Select all

return;
Comment out all instances of:

Code: Select all

trigger_error
Commenting those out may be specific to the Authorize.net AIM module but at least in my case it was required to keep the json response from containing this error:

Code: Select all

<b>Notice</b>: Error: Password not accepted from server!
If you don't want to comment all of those out you should at least comment out the one that's showing up in your error log.

Hope this helps someone down the road! This works but it's a pretty hacktastic approach so anyone with a better solution please feel free to share!!

New member

Posts

Joined
Sun Jul 25, 2010 10:50 pm

Post by JGAN » Sun Dec 03, 2017 7:28 am

Late but thanks for the tip!

New member

Posts

Joined
Wed Jan 13, 2016 7:52 pm
Who is online

Users browsing this forum: No registered users and 33 guests