Sending Emails in WooCommerce
MariiaHlumilina
Posted on March 14, 2023
In 2022, WooCommerce had a market share of 36.68%, making it the leading e-commerce platform worldwide. Online stores use transactional emails to send notifications to their customers, such as receipts or order confirmations. So, WooCommerce also needs a working email-sending functionality.
As a WordPress plugin, WooCommerce uses the native wp_mail()function to send emails, which is far from ideal. This means that emails addressed to your customers might not get sent or delivered to the inbox. They might even get discarded by the receiving mail servers.
Transactional emails in WooCommerce: definition, importance, examples
Transactional emails are emails that are triggered when a user takes a specific action.
For example, when you forget your super difficult password (mydogmax111) for the 100th time and request a reset, you’ll receive an email with a password reset link. That would be a transactional email.
Such emails are important as they provide users with necessary information about further steps, confirm their action, or let them know if something was unsuccessful. Refer to this article to learn more about WordPress transactional emails.
By default, WooCommerce includes certain types of transactional emails that can be modified to match your needs. These are usually WooCommerce order emails:
- New order – sent to site administrators
- Canceled order – sent to site administrators
- Failed order – sent to site administrators
- Order on hold – sent to customers
- Processing order – sent to customers
- Completed order – sent to customers
- Refunded order – sent to customers
- Customer invoice / Order details – sent to customers
- Customer note – sent to customers
- Reset password – sent to customers
- New account – sent to customers
These templates are available in plain text, HTML, or multipart formats. You can use them as they are or change their color or banner image. For that, you’d need to access WooCommerce email settings and scroll down to the ‘Email template’ section.
It’s also possible to change a particular template, for example, processing order. Simply press the ‘Manage’ button across the template. Fill in the empty fields, such as email subject, heading, additional content, and choose the email type (text, HTML, or multipart). Finally, hit ‘Save changes’.
If that’s not enough and you need more tweaks, just copy the template file below those fields by pressing ‘Copy file to theme’.
Navigate to the ‘Appearance’ tab in the WordPress dashboard and choose ‘Theme file editor’. You’ll see the ‘Theme files’ tab on the right portion of the screen. Scroll down to find ‘WooCommerce’. Expand it and press ‘emails’ which will open the menu with the list of templates you copied.
Choose the template you want to tweak and start coding.
Note: it’s recommended to create a child theme and make changes there to avoid losing all the customizations in the parent theme.
WooCommerce’s default customization options are limited, but there are multiple plugins that can help with that (more on that below).
Though plugins enable you to customize the design, you still have to come up with the content yourself or use templates. Here’s an order confirmation template from Mailtrap:
Subject: Your [SERVICE] order confirmation
Your order is confirmed!
[NAME], thanks for shopping with us. Here are your order details:
[orderID]
[product + picture]
[quantity/other customizations]
[price_paid + payment method] // if payment by card, the last four digits should be used
[shipping + billing address]
We estimate that your order will arrive in 2-3 business days. Click the button below to track it.
TRACK YOUR ORDER
Forgot to add something? Here are the items our clients frequently buy together with [PRODUCT]. Get them within the next 24 hours, and we’ll ship everything together.
[FAQs]
Need any support? Send a reply to this message or contact us right away [link].
Thanks for your order and we hope you enjoy!
How to send emails in WooCommerce with the WP Mail SMTP plugin
As mentioned above, it’s possible to send emails programmatically from WooCommerce with the WordPress wp_mail() function. It calls PHP’s mail()function, which in turn connects with the local host to send emails. Check out this blog post to find more information about sending emails in WordPress.
Without header authentication, PHP’s mail() function is often blocked by WordPress hosting providers. Email servers don’t tolerate this function either, putting incoming emails in the spam folder.
But that’s not the only issue. WooCommerce emails might not be sent or delivered for other reasons as well (refer to the troubleshooting section below for more details).
WP Mail SMTP plugin (or any other SMTP plugin, for that matter) solves those problems by overriding the mail() function and allowing users to configure WordPress SMTP settings.
This plugin connects Gmail SMTP or third-party SMTP service. By doing so, it enables you to send multiple emails from your WooCommerce store regardless of your web host.
Sending custom emails
You’ll have to send custom emails if you want to send after-purchase emails from WooCommerce.
Surprisingly enough, you can’t send email after order to your customers by default. The new order, canceled order, and failed order are all addressed to site administrators.
The native way of sending custom emails is a bit complicated. You’ll need to create an email manager class, extend WC_Email classes, and then build a custom template in plain text and HTML formats. That way, you’ll be able to send HTML email when it’s supported. If not, the email will be displayed in plain text format.
When the custom order emails are created, they will appear in Woocommerce settings.
You can also use ready-made WooCommerce templates and modify them.
If you prefer to use a plugin, you’ll need a premium Follow-Ups plugin. It will help you notify your customers when you’re updating orders (or any other event) or send emails to vendors directly from WooCommerce.
You can find more info on how to send emails with WooCommerce on the Mailtrap Blog.
Posted on March 14, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.