DEV Community

Artem (tema.name)
Artem (tema.name)

Posted on Fully Autonomous

WordPress or WooCommerce not sending emails? Fix it in this order

Order confirmations do not arrive, contact form messages disappear, password reset emails end up in spam. This is one of the most common WordPress problems, and in most cases the reason is the same: WordPress sends mail through PHP mail() from a server that mail providers do not trust.

Here is the order I check things on client sites.

1. Find out if mail is sent at all

Install a mail logging plugin (WP Mail Logging, or the log in your SMTP plugin) and trigger a test: a contact form message or a WooCommerce test order.

  • Nothing in the log: the form or plugin never called wp_mail(). Check the form settings and the WooCommerce email settings (each email type can be disabled).
  • In the log, but not delivered: WordPress did its part, the problem is delivery. Continue below.

2. Stop using PHP mail()

Shared hosting servers send mail from an IP that also sends mail for hundreds of other sites. Gmail and Outlook treat it with suspicion. Send through a real mailbox instead:

  • your domain mailbox (the SMTP server from your hosting or Google Workspace / Microsoft 365)
  • or a transactional service (Brevo, Postmark, Amazon SES, Mailgun)

Use an SMTP plugin (WP Mail SMTP, FluentSMTP, Post SMTP) and send a test email from its settings page.

3. The "From" address must match the domain

A common mistake: the site sends as [email protected], but SMTP logs in as [email protected]. Providers see a mismatch and reject or hide the message. Send from an address on your own domain and authenticate as that address.

Contact forms should use the visitor's email in Reply-To, not in From.

4. SPF, DKIM, DMARC

Without these DNS records, even correct SMTP mail lands in spam.

  • SPF: lists the servers allowed to send for your domain. Only one SPF record per domain.
  • DKIM: a signature your mail service gives you as a DNS record.
  • DMARC: tells receivers what to do with mail that fails the checks. Start with p=none.

Send a test to a checker like mail-tester.com and fix everything it marks red.

5. WooCommerce specifics

  • Check WooCommerce > Settings > Emails: every email type has its own on/off switch and recipient.
  • If emails stopped after an update, look for a plugin that overrides email templates.
  • Order emails are sent in the background on some setups. If WP-Cron does not run (low traffic or disabled cron), emails are delayed. Set up a real server cron.

6. Test like a customer

Place a real test order with a Gmail and an Outlook address. Check inbox, spam and promotions. Only then call it fixed.


If you would rather hand it over: I set up SMTP, DNS records and test delivery for WordPress and WooCommerce sites. Details: WordPress and WooCommerce email setup.

Top comments (1)

Collapse
 
alhiane profile image
Alhiane Lahcen •

Step 1 is the one most people skip, and it splits the problem in half right away. Two additions for when the log shows "sent" but nothing arrives, or shows nothing:

  • Log the actual PHPMailer error. WordPress fires wp_mail_failed with the reason (auth failed, connection refused, and so on), but nothing records it by default. A tiny mu-plugin does it:
<?php
add_action( 'wp_mail_failed', function ( $error ) {
    error_log( 'wp_mail_failed: ' . $error->get_error_message() );
} );
Enter fullscreen mode Exit fullscreen mode
  • Check for two mail plugins at once. An SMTP plugin plus a form plugin's own SMTP setting, or two SMTP plugins after a migration, both change PHPMailer and the last one wins. wp plugin list --status=active and look for anything mail-related. If mail stopped right after a plugin update and nothing is logged, wp eval 'var_dump( has_filter( "pre_wp_mail" ) );' tells you if something is short-circuiting wp_mail() before it sends.

To test without placing an order: wp eval 'var_dump( wp_mail( "[email protected]", "test", "body" ) );'