Fixing woocommerce error

[Solved] Woocommerce wordpress not sending emails – How to fix

Pinterest LinkedIn Tumblr

Email not sending emails when customer place order on your Woocommerce WordPress website is a common error that many WordPress and Woocommerce users encounter when running a website in WordPress.

In most cases, this error happens when your hosting provider disabled php mail() function so that the server did not send mail when there’re requests from the user.

In this tutorial, I will give all possibilities why Woocommerce does not send mail when customer placing order or other actions on your store and how to fix them.

Type of mail Woocommerce send to customer

There’re many types of email that Woocommerce will send to your customer, you can turn on/off email that you don’t want in Email setting section of Woocommerce.

woocommerce does not send mail 1

My recommendation is that you should turn on only important type of email like: New Order, Refunded Order, Processing Order, Reset Password, New account, Completed order email to avoid auto spam filter from E-mail provider

  • Cancelled order: When customer cancel an order, Woocommerce will send mail to notify them that the order was cancelled succesfully
  • Failed order: Notify customer about failed order
  • Order on-hold: Order can not be processed now for some reason
  • Processing order: Order is being processed by staff
  • Completed order: Completed order
  • Refunded order: orders that were successfully refunded
  • Customer invoice / Order details
  • Customer note: note from buyers
  • Reset password: Reset password instruction email
  • New account: new account information

Causes of the error

There’re many possibilities that caused this error, I will list the most common causes here

1. Mail () function not enable on your hosting

This is the most common issue, hosting provider usually block this function to avoid threats like hacking, spam, DDOS …. for their server.

To check if mail() function is enabled on your server, create a test.php file with the following code lines:

<?php
if ( function_exists( 'mail' ) )
{
    echo 'mail() is enabled';
}
else
{
    echo 'mail() has been disabled';
}
?>

To check if email sending is enabled, use the following code snippet

/**
 * @snippet       check if email sending is enabled in WooCommerce
 * @author        wooexplorer.com
 */
<?php 

$email = "yourreceivingemail@gmail.com";
$subject =  "Test sending email from Woocommerce";
$message = "This email is sending to test php mail function";


$sendMail = mail($email, $subject, $message);
if($sendMail)
{
echo "Emai was sent Successfully";
}
else

{
echo "Failed to send email";
}
?>

If you’re using a VPS with ssh access, put the following command in your ssh client:

Check if mail function is enabled

which sendmail

Send email using Linux command

echo "Subject: sendmail test" | sendmail -v my@email.com

2. Mails go into spam folder

Most email providers will block emails sent from a hosting/vps and move them to spam folder of receiver. This is why I do not recommend using Hosting/VPS to send email even if mail() function is enabled by provider

If mail() function is already enabled by you still cannot find email inbox then go to spam folder to check

mail in spam

If you find emails sent from your site in spam folder, I recommend using SMTP to avoid spam filter (I guide you explain step by step how to install and use SMTP for Woocommerce in Solution part)

3. Email notification not enabled in setting of Woocommerce

By default, email notification is enabled in Woocommerce setting. But if you’ve done all the steps above but there’s no email sent, then do a recheck in Woocommerce email setting.

In WordPress admin, navigate to: WooCommerce > Settings > Emails

email setting woocommerce

Select a type of email you want to check, eg: New order email then check if “Enable this email Notification”  option is enabled

enable email notification woocommerce

After you’re done, save setting and recheck

Email sender option contains special characters

This is also a cause why email is not sending in Woocommerce. In Email setting, double-check if Email Sender options are correct.

Make sure that: “From” name and “From” address does not contain special characters such as “@/.&-”, only use normal letters to fill in these fields

email sender option

Solution

Using SMTP server to send Woocommerce email is currently the best fix for this issue

What is SMTP

SMTP (Simple Mail Transfer Protocol) is a standard for sending emails. Unlike the PHP mail function, SMTP uses proper authentication which increases the ability to send email.

In short, we will send order emails to customers from trusted provider like Gmail, Yahoo, Hotmail… to increase creadibility and bypass “blocked mail function”  from hosting provider

How to install and configure SMTP for Woocommerce WordPress site

In this article, I will guide you to fix the error “error of not sending wordpress email” with a very popular SMTP plugin that is WP SMTP.

STEP 1: Install WP SMTP Plugin

You can get the plugin here: https://wordpress.org/plugins/wp-smtp/

Or simply, just search for WP SMPT in plugin search box

wpsmtp

STEP 2: Enable 2-Step Verification

In this tutorial, I will set up SMTP using the most popular email provider: Gmail, if you are using other providers, drop a comment below and I will guide you.

To set up gmail smtp you need to turn on 2-Step Verification function for google account if access is not enabled

Go to https://myaccount.google.com/security select 2-Step Verification

2-Step Verification gmail

Select Get Started

2-Step Verification gmail 2

Select phone you wish to use as verification phone (if you can’t find your phone, just add google account on your phone, follow these steps on Android and Iphone)

add google account on phone

Finally click on Try It Now

On your phone, click on Yes to verify phone

verify email

Insert Phone number and you will receive a text message with a verification code

Insert that code into google confirmation page and you will finish 2-Step Verification process

finish

finish 2

Next, visit the website https://security.google.com/settings/security/apppasswords to create a new “generate app password Gmail“.

Select the app and device you want to generate the app password for.

select device

Finally, click on Generate button to create APP password.

app password

In this example, your new APP password is: xaty jbdc lrtc xyvx

STEP 3: Configure WP SMTP Plugin

Now, go back to admin => Setting => Wp SMTP and insert the following information

  • From: Your desired “From email”
  • From Name: Name of sender
  • SMTP Host: SMTP host is different from different providers, normally, you can easily obtain SMTP host detail from setting section in your mailbox. If you are using Gmail, this is smtp.gmail.com
  • SMTP Secure: Select SSL for Gmail
  • SMTP Port: insert port 465
  • SMTP Authentication: Select Yes
  • Username: Your login email username, for example: Wooexplorer@gmail.com
  • Password: App password we generated in step 2, eg: xaty jbdc lrtc xyvx

wpsmtp setting

Finally, save changes

STEP 4: Send Test email

Now you can send test email to test if Woocommerce is sending email properly using Gmail SMTP server

send test mail

Check your inbox, the test email should be there. From now, Woocommerce sending-email will function properly

received email

Hung Tran is the author of Wooexplorer.com, he loves to share knowledge about Woocommerce and Wordpress

1 Comment

  1. If you still experience email sending error after following my guide, please drop a comment here and I will check it for you!

Write A Comment