Support » Plugin: WP Mail SMTP by WPForms » Compatibility with WooCommerce

  • Resolved thisisbbc

    (@thisisbbc)


    Hello guys,

    We’ve been using your plugin for a little while now and really love its simplicity.

    Recently we discovered a weird behavior with 2 WooCommerce e-mails templates:

    -> Admin new order notification
    -> Customer new order receipt

    These e-mail are signed by our hosting provider server instead of SendGrid, telling us they are not going through WP Mail SMTP. These are the automatic e-mails sent when a new order comes in.

    I’m emphasizing on the automatic part here because when we fire these e-mails manually from the order back-end, they are indeed signed by our domain via Sendgrid. It’s when an order is filled and the notifications are sent automatically that they are not signed.

    I dug up the send() function (line 548) in the WC_Mail class, hopefully it can help : https://docs.woocommerce.com/wc-apidocs/source-class-WC_Email.html#11-953

    Any help to get those e-mails through Sendgrid would be appreciated!

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Slava Abakumov

    (@slaffik)

    Hi @thisisbbc

    I see that it’s using wp_mail() to send everything, so it should be good.
    Are you sure the issue is with these 2 emails? WC sends a bunch of other types of emails automatically too, so I’m wondering whether it happens with these 2 or all emails that it sends when processing orders.

    Have you tested on a staging site with no custom code and only WP Mail SMTP and WooCommerce activated? Perhaps, there is some plugin (or code in a custom plugin or theme functions.php file) that overwrites default behavior.

    Hello Slava,

    Thank you for the quick reply.

    We found the culprit, we use an optimization plugin called Plugin Organizer.

    We had set WP Mail SMTP to be disabled globally as we were under the impression all the magic happened in the back-end but apparently you still need to call something from the front-end to fire your function.

    Since I was not able to pinpoint which WooCommerce page(s) needs WP Mail SMTP to be enabled to work properly, can you tell me what hook your plugin is using to replace the wp_mail() function?

    To fix our issue we have to:
    -> Disable WP Mail SMTP globally (optional, but good for optimization)
    -> Enable WP Mail SMTP on all “page” post_type
    -> Disable WP Mail SMTP on all “post” post_type (optional, but good for optimization)

    When we do this it works.

    Since we do not need to send an e-mail on every pages, we’d like to enable WP Mail SMTP strictly for the required pages like the checkout page. This is what we tried:

    -> Disable WP Mail SMTP globally
    -> Disable WP Mail SMTP on all “page” post_type
    -> Disable WP Mail SMTP on all “post” post_type
    -> Override “page” post_type rule and enable WP Mail SMTP on site.com/checkout/*

    Did not work.

    We also tried to add the following rules:

    -> Override “page” post_type rule and enable WP Mail SMTP on site.com/cart/*
    -> Create plugin filters permalink rule and enable WP Mail SMTP on site.com/wp-admin/admin-ajax.php*

    Did not work as well.

    If we can pinpoint the right page / permalink structure to enable WP Mail SMTP, we will be able to only enable it when it is needed.

    Appreciate the help!

    Thank you.

    Plugin Author Slava Abakumov

    (@slaffik)

    WP Mail SMTP does not rewrite wp_mail() function. We replace its internal global variable $phpmailer (that us used to send emails) with own class, that has extended functionality and provides gateways for various Mailers that we support.

    WC sends emails in various situations: on checkout, it has own background queue for them too (so they are sent separately from WP core logic), from admin area etc – I can’t help to pinpoint all such places as I’m not a WC expert right now.

    Your best solution would be to leave it as is, as sending emails is very basic and important core WP functionality, and other plugins may be affected to.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.