Skip to content

WordPress Not Sending Email? How to Fix It With SMTP

WordPress not sending email? Learn why PHP mail() fails or lands in spam, then fix it with authenticated SMTP via a plugin or wp-config, and test delivery.

By Devma Hosting Team · · 10 min read

A small-business desk with a closed laptop, a stack of envelopes in a mail tray, a coffee mug and a router with glowing lights in soft morning light.

If WordPress is not sending email, the usual cause is that it relies on PHP's built-in mail() function, which either isn't set up on your server or sends unauthenticated messages that Gmail and Outlook treat as suspicious. The fix is to route WordPress mail through an authenticated SMTP server, using a plugin or a few constants in wp-config.php, then test delivery and check the logs.

Key takeaways

  • By default, WordPress's wp_mail() hands messages to PHP's mail() function, which needs a working sendmail-compatible program on the server. If that program is missing or disabled, email fails.
  • A "Message sent" notice or a true return from wp_mail() only means WordPress processed the request without an error. It does not mean the email reached an inbox.
  • Authenticated SMTP (port 587 with STARTTLS or port 465 with TLS) through a real mailbox or sending service fixes most delivery and spam problems.
  • Your From address should use a domain you control, with SPF, DKIM and DMARC records that authorize your SMTP provider.
  • Google no longer accepts plain password SMTP logins, and Microsoft is retiring Basic auth for SMTP in Microsoft 365, so use App Passwords or OAuth with those services.

Why is WordPress not sending email?

How WordPress sends email by default

Almost every email your site sends (password resets, new user notices, WooCommerce order emails, most contact form messages) goes through wp_mail(). According to the WordPress mail documentation, this wrapper tells the bundled PHPMailer library to use PHP's internal mail() function, which "requires the presence of a sendmail-compatible binary acting as the MTA."

In plain terms, WordPress doesn't deliver email itself. It asks the server to do it. That breaks in a few common situations:

  • The server has no mail transfer agent installed, or it's misconfigured. This is common on fresh VPS builds and containers.
  • The host disables or limits PHP mail to stop compromised sites from sending spam.
  • Outbound port 25 is blocked, which many hosts and cloud providers do by default.

Why "sent" doesn't mean delivered

The wp_mail() function reference is clear that a true result only means the sending method processed the request without errors. It tells you nothing about whether the receiving server accepted the message, filed it as spam or dropped it.

That's why a contact form can happily say "Thanks, your message was sent" while nothing ever arrives.

Why WordPress emails go to spam

Even when mail() works, messages often land in junk. The email leaves from your web server's IP address with no login and no signature, and the From address (by default something like wordpress@yourdomain.com) belongs to a domain whose DNS usually doesn't authorize that server. Receiving servers check SPF, DKIM and DMARC, see a mismatch, and treat the message as suspicious.

Mailbox providers have also tightened their rules. Google's email sender guidelines require everyone sending to Gmail to have SPF or DKIM, valid forward and reverse DNS for the sending IP, a TLS connection and low spam complaint rates. Bulk senders (5,000 or more messages a day to personal Gmail accounts) also need DMARC and domain alignment. Microsoft introduced similar requirements for high-volume senders to Outlook.com in 2025.

Most WordPress sites send nowhere near bulk volumes, but the baseline rules still apply, and unauthenticated mail() traffic often fails them.

Step 1: Test whether WordPress email works at all

Before changing settings, confirm what's actually happening.

  1. Trigger a real WordPress email. Log out, use "Lost your password?" on the login page for a test account, or submit your own contact form.
  2. Send to more than one provider. Use a Gmail and an Outlook.com test address so you can compare results.
  3. Check every folder. Look in the inbox, spam or junk, and Gmail's Promotions tab.
  4. Test from the command line if you have WP-CLI. This shows exactly what wp_mail() returns:
wp eval 'var_dump( wp_mail( "you@example.com", "WP test", "Testing wp_mail from WP-CLI" ) );'
  1. Read the headers of any message that arrives. In Gmail, open the message, click the three-dot menu and choose "Show original" to see SPF, DKIM and DMARC results. Outlook.com lets you view the message source from the message menu.

Use what you find to decide where to go next:

What you see Likely cause Where to go
Nothing arrives and wp_mail() returns false PHP mail missing or disabled on the server Steps 3, 4 and 6
Nothing arrives but wp_mail() returns true Rejected or dropped after leaving WordPress Steps 2 and 6
Arrives in spam, SPF or DKIM fails Unauthenticated sending Steps 2 to 5
Arrives in the inbox, all checks PASS Working correctly Keep monitoring

Step 2: Choose an SMTP server to send through

With SMTP, WordPress logs in to a real mail server with a username and password (or an OAuth token) and hands over the message, the same way your email app does. The receiving side sees mail from a known, authenticated source instead of an anonymous web server.

Option Good for Watch out for
Mailbox from your host or business email provider Contact forms and low-volume sites Hourly or daily sending limits
Google Workspace Teams already using Workspace App Password or OAuth required
Microsoft 365 Teams already using Microsoft 365 Basic auth SMTP is being retired, so plan for OAuth
Transactional email service (SMTP or API) Stores, membership sites, higher volume Domain verification and extra DNS records

Whichever you choose, send from an address on your own domain and make sure that provider is authorized in your DNS (more on that in Step 5).

Using Gmail or Google Workspace for SMTP

Google has ended "Less Secure Apps" access, which was the old way of logging in to SMTP with just your normal password. Google announced the wind-down in 2023 and it is now complete. Your options are an App Password (which requires 2-Step Verification on the account) or a plugin mailer that connects through Google OAuth.

Using Microsoft 365 for SMTP

Microsoft announced the retirement of Basic authentication for SMTP AUTH client submission and has revised the timeline several times. According to the most recent guidance reported by Office 365 for IT Pros, existing tenants can keep using Basic auth until the end of December 2026, and new tenants created from early 2027 won't have it. Because dates have shifted before, check Microsoft's latest announcement, but don't build anything new on username and password SMTP to Microsoft 365. Use a plugin mailer that supports Microsoft OAuth instead.

Step 3: Fix WordPress email with an SMTP plugin

For most site owners, a plugin is the quickest fix. Popular options include WP Mail SMTP, FluentSMTP and Post SMTP. Pick one and install only one, since two SMTP plugins will fight over the same settings.

The general process with WP Mail SMTP looks like this (other plugins are similar):

  1. Install and activate the plugin from the Plugins screen in your dashboard.
  2. Set the From Email to an address on your domain, such as hello@yourdomain.com, and enable the option to force it, so other plugins can't override it.
  3. Choose a mailer: a generic "Other SMTP" option for any mail server, or a dedicated mailer for Google, Microsoft or a transactional service.
  4. Enter the SMTP host, encryption (TLS for port 587, SSL for port 465), port, and turn on authentication with your username and password or App Password.
  5. Save, then use the plugin's built-in test email feature and repeat the checks from Step 1.

WP Mail SMTP encrypts the SMTP password it stores in the database, but you can keep credentials out of the database entirely by defining them in wp-config.php. Place these above the /* That's all, stop editing! */ line. This example is based on DreamHost's WP Mail SMTP guide:

define( 'WPMS_ON', true );
define( 'WPMS_MAIL_FROM', 'hello@yourdomain.com' );
define( 'WPMS_MAIL_FROM_FORCE', true );
define( 'WPMS_MAIL_FROM_NAME', 'Your Business' );
define( 'WPMS_MAIL_FROM_NAME_FORCE', true );
define( 'WPMS_SET_RETURN_PATH', true );
define( 'WPMS_MAILER', 'smtp' );
define( 'WPMS_SMTP_HOST', 'smtp.yourprovider.com' );
define( 'WPMS_SMTP_PORT', 587 );
define( 'WPMS_SSL', 'tls' );
define( 'WPMS_SMTP_AUTH', true );
define( 'WPMS_SMTP_AUTOTLS', true );
define( 'WPMS_SMTP_USER', 'hello@yourdomain.com' );
define( 'WPMS_SMTP_PASS', 'your-app-password' );

With WPMS_ON set to true, these constants take priority over the values on the plugin's settings screen. API-based mailers have their own constants for API keys, listed in the plugin's documentation.

Fix your contact form's From address

Many contact form plugins can put the visitor's email address in the From field. That breaks authentication, because you're sending "as" a domain like gmail.com that never authorized your server. Set the form's From to your own domain address and put the visitor's address in Reply-To, so hitting Reply still goes to them.

Step 4: Configure WordPress SMTP without a plugin

If you prefer code, WordPress exposes the phpmailer_init hook, which fires after PHPMailer is initialized. You can switch it to SMTP there. First, add your credentials to wp-config.php:

define( 'SITE_SMTP_HOST', 'smtp.yourprovider.com' );
define( 'SITE_SMTP_PORT', 587 );
define( 'SITE_SMTP_SECURE', 'tls' ); // 'tls' for 587, 'ssl' for 465
define( 'SITE_SMTP_USER', 'hello@yourdomain.com' );
define( 'SITE_SMTP_PASS', 'your-app-password' );
define( 'SITE_SMTP_FROM', 'hello@yourdomain.com' );
define( 'SITE_SMTP_FROM_NAME', 'Your Business' );

Then create a must-use plugin at wp-content/mu-plugins/smtp.php. A must-use plugin keeps working if you change themes, unlike code in functions.php:

<?php
/**
 * Plugin Name: Site SMTP
 */
add_action( 'phpmailer_init', function ( $phpmailer ) {
    if ( ! defined( 'SITE_SMTP_HOST' ) ) {
        return;
    }
    $phpmailer->isSMTP();
    $phpmailer->Host       = SITE_SMTP_HOST;
    $phpmailer->SMTPAuth   = true;
    $phpmailer->Port       = SITE_SMTP_PORT;
    $phpmailer->Username   = SITE_SMTP_USER;
    $phpmailer->Password   = SITE_SMTP_PASS;
    $phpmailer->SMTPSecure = SITE_SMTP_SECURE;
    $phpmailer->From       = SITE_SMTP_FROM;
    $phpmailer->FromName   = SITE_SMTP_FROM_NAME;
} );

Don't combine this with an SMTP plugin. WP Mail SMTP also works through phpmailer_init, and your own callbacks still run alongside it, with hook priority deciding which settings win. Changing the sender in custom code can quietly undo the plugin's From settings and hurt deliverability.

While you're editing wp-config.php, it's worth reviewing the other hardening steps in our WordPress security checklist.

Step 5: Authenticate your domain with SPF, DKIM and DMARC

SMTP gets your mail sent from a trusted server. DNS records prove that server is allowed to send for your domain. We cover how each record works in SPF, DKIM and DMARC Explained, so here's just the checklist for a WordPress switch:

  1. SPF: add your SMTP provider's include or IP to your existing SPF record. Keep a single SPF record per domain rather than adding a second one.
  2. DKIM: publish the DKIM key your provider gives you as a DNS record, then enable signing in the provider's dashboard.
  3. DMARC: if you don't have one yet, start with p=none so you can monitor reports before tightening the policy.

Our SPF & DMARC Generator builds valid records, and the DNS Lookup tool confirms they're live. If TXT records are new to you, start with DNS Records Explained.

Step 6: Check the logs when WordPress email still fails

When messages still don't arrive, get the real error message instead of guessing. The wp_mail_failed action, available since WordPress 4.4.0, fires whenever PHPMailer throws an exception and passes a WP_Error containing the error message and the email details.

Turn on debug logging in wp-config.php:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Then add this to your must-use plugin:

add_action( 'wp_mail_failed', function ( $error ) {
    error_log( 'wp_mail failed: ' . $error->get_error_message() );
} );

Send another test and open wp-content/debug.log. Two errors come up often:

  • "SMTP connect() failed": the host, port or encryption is wrong, or a firewall is blocking the outbound port. Double-check the provider's settings and ask your host whether ports 587 and 465 are open.
  • "Could not authenticate": the username or password is wrong, an App Password is required, or Basic auth has been disabled on the account.

If debug.log is clean, look further down the chain: your SMTP plugin's email log (if it has one), your host's mail logs, and the activity or bounce log in your SMTP provider's dashboard. Those show whether the receiving server accepted, deferred or rejected each message.

When you're done, set WP_DEBUG back to false so you aren't logging indefinitely.

Common mistakes that keep breaking WordPress email

  • Trusting the "sent" message. A success notice only means WordPress handed the email off without an error.
  • Using a From address you don't control. Sending "from" a gmail.com or visitor address through your server fails DMARC alignment.
  • Using your normal Google password. It won't work for SMTP anymore. Use an App Password or OAuth.
  • Relying on Basic auth SMTP to Microsoft 365. Existing tenants are running out of time, so move to OAuth.
  • Storing credentials in theme files. Keep them in wp-config.php, which also survives theme updates.
  • Running two SMTP plugins, or an SMTP plugin plus custom phpmailer_init code.
  • Using port 25 or mismatched encryption. Pair 587 with TLS and 465 with SSL.
  • Forgetting email after a move. A new server or IP can silently break mail() and SPF, so retest as part of any WordPress migration.

Get reliable email for your WordPress site

The most dependable setup is simple: a real mailbox on your own domain, authenticated SMTP from WordPress, and correct SPF, DKIM and DMARC records. If you need a mailbox to send from, Devma Hosting Business Email gives you addresses on your own domain. Use the SMTP host, port and credentials for your mailbox with an SMTP plugin or the wp-config method above. If you're also comparing hosts for your site, see our WordPress Hosting plans.

Frequently asked questions

What SMTP port should WordPress use?

Use port 587 with STARTTLS (select TLS in most plugins) or port 465 with implicit TLS (select SSL). Avoid port 25, which many hosts and cloud providers block for outbound mail. Your email provider's documentation lists the exact host, port and encryption it expects.

Can I use a free Gmail account as my WordPress SMTP server?

Yes, but only with an App Password (which requires 2-Step Verification) or an OAuth-based mailer, because Google no longer accepts plain password logins for SMTP. Gmail generally sends as the account you authenticate with, so the From address won't match your own domain. For a business site, a mailbox on your own domain is the better choice.

Why did WordPress email stop working after I moved to a new host?

The new server may not have a working mail program, may block PHP mail() or outbound port 25, or may use an IP address your SPF record doesn't authorize. Switching to authenticated SMTP removes the dependency on the server's local mail setup. Also confirm your MX, SPF and DKIM records still point to the right provider after the move.

Is it safe to store SMTP passwords in wp-config.php?

It is safer than hard-coding them in a theme file and keeps them out of the database and the admin screens. wp-config.php should already be protected because it holds your database credentials. Use an App Password or a dedicated sending credential so you can revoke it without changing your main mailbox password.

How many emails can WordPress send through SMTP?

There's no WordPress limit, but your SMTP provider sets one. Mailboxes from hosts and business email providers usually cap messages per hour or per day, while transactional email services are built for higher volume. Check your provider's sending limits before running newsletters or busy stores through a regular mailbox.

Abstract blue swirling shapes with light reflections

Ready when you are.

Pick a plan and launch today, or tell us what you run and we will size it with you.

Devma Hosting

AI assistant · replies in seconds

Hi there.
How can we help?

Ask about plans, moving your site, email or security. Answers come from our own guides, and a person is one tap away.

  • Message us on WhatsApp