WooCommerce Hack #3 – monitoring outbound emails

Here’s a little hack that I use to monitor the outbound emails to my customers.

When I initially set my site up, I went through and tested everything, even making a test purchase of a random product.  Everything worked perfectly.

Then a few sales down the track, I had this funny feeling in the back of my mind that customers emails weren’t going out.  I’d added my mobile phones email address to the ‘New Order’ email notification, so I’d always know when I’d made a sale.  But the alerts had stopped, only to be (pleasantly) surprised that I’d made sales when logging into my store.

So after adding this little code, I found NO emails were going out at all, which was cause for concern.  I did find the cause and solution, which was a simple setting, but still to this day I don’t know if I overlooked it in my initial setup of the store…  I’ll get around to that one day…  Simply, my host was blocking outbound emails from Woo.

…the code.

Again, simply copy this code and paste it into your functions.php file of your Child Theme.  Follow all the precautions in Hack #1 (I’ll get around to making this repetitive instructions their own post one day)

//
// Start - add BCC to all outgoing emails
//

add_filter( 'woocommerce_email_headers', 'add_bcc_all_emails', 10, 2);
 
function add_bcc_all_emails($headers, $object) {
 
    $headers = array();
    $headers[] = 'Bcc: Name <alerts@domain.com>';
    $headers[] = 'Content-Type: text/html';
 
    return $headers;
}

//
// End - BCC out
//

Change the email address to something that you’d like.  This will simply add your email address to the BCC field of every email that Woo sends out.  The customer will never know.

This is an example of what I have done, allowing for expansion into multiple stores.

I have a primary business domain.  It doesn’t host a store, it’s like my holding or bucket company.

I went into the email options in cPanel for that domain.  I then created a ‘forwarder’ account called ‘alerts@domain.com’ and forwarded that email address to ‘iphone@domain.com’.  I also added my partners’ email addresses to the forwarder as well.

So it looks something like this:

alerts@domain.com -> myiphone@domain2.com
alerts@domain.com -> partner55@gmail.com
alerts@domain.com -> partner-c@hotmail.com

So anytime an email is sent to alerts, all 3 of us get it.  And because it’s setup on one domain, I don’t need to do it for each store I setup up.  Do the work once!!

Now, go forth and sell some knife sharpeners…

Leave a Reply