In order to improve the performance of a website I built some years ago, I moved the site from an Apache based CentOS + Plesk setup to an nginx based Ubuntu + EasyEngine setup, late last year.
In the beginning there were some struggles with certain functionality on the site, but I was able to resolve almost all issues in the days after the setup. One issue though, has been continuously haunting me since the move to the EasyEngine setup:
When a customer creates an order in the webshop (WooCommerce) the confirmation emails are not always being created or sent. This happens with different types of products, payment methods, coupons etc. Up until today I’ve been unable to pin down where this discrepancy is coming from.
So that’s the problem, now some more insights into the configuration:
- Server: VPS with 2 Xeon CPU’s, 4GB RAM and 150GB SSD server grade storage.
- Server Configuration: Ubuntu with latest version of Easy Engine.
- EasyEngine site configuration: WordPress with PHP7 and wpredis.
- Caching configuration: Cart, Checkout and Account excluded from redis cache (x-srcache-fetch-status:BYPASS, x-srcache-store-status:BYPASS) through nginx configuration file. Redis Object Cache Plugin in WordPress.
- Webshop: WooCommerce with Pronamic iDEAL for payments and WooCommerce Print Invoices/Packing Lists for Invoicing purposes.
Troubleshooting:
- I’ve verified that non of the relevant WooCommerce pages are being cached by looking for the BYPASS fetch-status and store-status value. Dump of the .conf file underneath.
- Initially I ran into this problem while the server was configured to deliver email through and smtp relay service provided by the VPS host. As this relay service did not provide any statistics on (non)successful deliveries, I decided to change to mail delivery to the MailGun API, as this would allow me to exclude the mail server as the problem as well as receive more insights into delivery statistics.
- MailGun is displaying very healthy delivery statistics with less than 0.3% of emails being bounced or being marked as undeliverable. MailGun looks specified the usual reasons for misdelivery: mailbox full, mailbox does not exist. At this point I was quite certain that the mail delivery service was not the culprit.
- As MailGun is doing it’s job, I decided to start looking into WordPress. Are the mails being created in WordPress and do they get stuck, or do they simply never get made? In order to troubleshoot this, I installed the WP Mail Logging plugin. After being enabled for a couple of weeks I compared WP Mail Logging against logs in MailGun. The results were identical. So it looks like all the mails that get created are successfully delivered to MailGun. Non of the mails in WP Mail Logging display errors.
At this point I started thinking that WooCommerce is unable to successfully create these emails, however it seems to be completely random if or when the emails are or aren’t created, making it very hard to troubleshoot. An extreme example: On May 7th, WP Mail Logging and MailGun display the successful delivery of the new order (admin), new order (client) and your invoice (client) emails for one order. A couple of new account (client) emails were created as well. However, on this day 13 orders were created with the same status (processing). These orders did not trigger the expected new order (admin), new order (client) and your invoice (client) emails.
Any thoughts on further troubleshooting?
Thank you!
Dump of the custom cache exclusion configuration file in conf/nginx/
Don’t serve cached pages when items have been added to cart.
if ( $cookie_woocommerce_items_in_cart = “1” ){
set $skip_cache 1; }
Don’t cache uris containing the following segments.
if ($request_uri ~* “(/cart.|/my-account.|/checkout.|/winkelwagen.|/mijn-account.|/afrekenen.|/winkelwagen/|/mijn-account/|/afrekenen/|/wp-admin/|/xmlrpc.php|sitemap(index)?.xml|[a-z0-9-]±sitemap([0-9]+)?.xml)”) {
set $skip_cache 1; }