New guide: how to warm up a dedicated IP without hurting your reputation. Read now →
Log in
MigoSMTP
TroubleshootingUpdated 4 Nov 2026

WordPress Emails Not Sending: SMTP Setup and wp_mail Fixes

Why WordPress emails fail or land in spam, how wp_mail and PHP mail() work, and how to fix it with authenticated SMTP, a phpmailer_init hook or a plugin, plus logging, DNS authentication and a troubleshooting table.

CL
Written by Camille Laurent
Email Marketing Strategist
Reviewed by Ethan Brooks
  • Published5 May 2024
  • Read time7 min
  • Length1,364 words
Share this guide

WordPress emails usually fail because the site sends through the web server's built-in PHP mail() function, which is unauthenticated and often blocked, rate limited or discarded by receivers. The reliable fix is to send through authenticated SMTP, either with an SMTP plugin or with a few lines of code that tell WordPress to use your relay on port 587 or 465, and to publish SPF, DKIM and DMARC records for the From domain.

This guide shows how to diagnose where the message is lost, how to configure SMTP, how to log failures that WordPress hides by default, and how to read the common symptoms. It applies to password resets, comment notifications, form plugins and any plugin that calls wp_mail().

Root causeDefault PHP mail() sends unauthenticated mail from the web host
FixAuthenticated SMTP with TLS plus SPF, DKIM and DMARC on the From domain
Key functionwp_mail() returns true when it hands the message to the mailer, not when it is delivered
First checkSpam folder, then logs, then DNS authentication

How WordPress sends email

Every WordPress email goes through wp_mail(), a wrapper around the bundled PHPMailer library. With no configuration, PHPMailer uses PHP's mail(), which passes the message to a local sendmail-style program on the server. That program has no login to a mail provider, the server's IP address may have a poor reputation or be shared with many sites, and the From address defaults to something like wordpress@yourdomain, which has no authentication tied to the sending server.

The result is a range of failures. The message may be rejected outright, quietly dropped by the host, accepted and then sent to spam, or never leave the server. Meanwhile wp_mail() reports success whenever the local handoff worked, so the site looks fine. Understanding this split between "handed off" and "delivered" is the key to debugging. See why emails will not send for the general picture.

Find where the message is lost

StageQuestionHow to check
WordPressDid wp_mail() run and return true?Log the result, or use a logging plugin
Web hostDid the host allow the connection or the mail() call?Ask the host, or test an SMTP connection to your relay
ProviderDid the relay accept the message?Provider logs or event webhooks
ReceiverWas it accepted, deferred or bounced?Bounce messages, headers, provider events
MailboxIs it in spam or a filter?Check spam and rules, then look at authentication results

Start at the top and move down. Many "not sending" cases are actually "sent but filed in spam", so check the spam folder and the recipient's filters before changing anything.

Step 1: add logging so failures become visible

Add this to a small must-use plugin or your child theme's functions.php. It records the error that PHPMailer returns, which WordPress otherwise discards. Enable WP_DEBUG_LOG in wp-config.php so that error_log() writes to wp-content/debug.log.

// wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

// must-use plugin or functions.php
add_action('wp_mail_failed', function ($error) {
    error_log('wp_mail failed: ' . $error->get_error_message());
});

Turn debugging off again when you have finished, and do not leave the log world-readable, because it can contain addresses and message details.

Step 2: send through authenticated SMTP

You can use a plugin or code. Plugins give a settings screen and sometimes logs and retries; code keeps the dependency count low. Whatever you pick, do not store the SMTP password in plain text in the database if you can avoid it. Define it as a constant in wp-config.php, which sits outside the web root on many setups and is not exposed by plugins.

// wp-config.php
define('MAIL_SMTP_HOST', 'smtp.migosmtp.com');
define('MAIL_SMTP_USER', 'smtp-username');
define('MAIL_SMTP_PASS', 'smtp-password');
define('MAIL_FROM', '[email protected]');

// must-use plugin: wp-content/mu-plugins/smtp.php
add_action('phpmailer_init', function ($phpmailer) {
    $phpmailer->isSMTP();
    $phpmailer->Host       = MAIL_SMTP_HOST;
    $phpmailer->SMTPAuth   = true;
    $phpmailer->Port       = 587;
    $phpmailer->SMTPSecure = 'tls';      // STARTTLS on 587
    $phpmailer->Username   = MAIL_SMTP_USER;
    $phpmailer->Password   = MAIL_SMTP_PASS;
    $phpmailer->setFrom(MAIL_FROM, get_bloginfo('name'), false);
});

For implicit TLS on port 465, set Port to 465 and SMTPSecure to 'ssl'. A must-use plugin loads automatically and cannot be deactivated from the dashboard by mistake. For port choice see choosing between ports 25, 465 and 587, and for the PHP library behind this, PHPMailer SMTP guide.

If you prefer a plugin, install a well-maintained SMTP plugin from the official directory, choose the generic SMTP option, and enter the same host, port, encryption, username and password. Check the plugin's recent update date and reviews, and avoid plugins that route your mail through an unknown third party. For form-specific setup, see WordPress contact form SMTP setup.

Step 3: align the From address and authenticate the domain

The From address must belong to a domain you control and have authenticated with the sending service. A mismatch is the most common reason for mail that is accepted but then rejected or junked. Use an address such as hello@yourdomain, not a free-mail address, and set SPF and DKIM as your provider instructs. Add a DMARC record so that receivers know what to do with failures. See authenticating your sending domain and the SPF, DKIM and DMARC checker.

Step 4: test properly

  1. Send a test with WP-CLI if you have it: wp eval 'var_dump(wp_mail("[email protected]", "Test", "Hello"));'.
  2. Or use a test button in your SMTP plugin, or trigger a password reset for a test user.
  3. Read debug.log for a wp_mail failed line.
  4. Open the delivered message and view the original headers. Confirm SPF, DKIM and DMARC pass. See reading email headers.
  5. Test two recipients on different providers, since filters differ.

Common causes and fixes

SymptomLikely causeFix
No email at all, no errorHost blocks outbound mail or disables mail()Switch to SMTP over 587 or 465; ask the host which ports are open
wp_mail failed: SMTP connect() failedPort blocked, wrong host or TLS settingCheck host, port and encryption; see connection timeouts
SMTP Error: Could not authenticateWrong credentialsRe-enter the password; see fixing 535 errors
Mail goes to spamNo SPF or DKIM, or a poor From addressAuthenticate the domain; see spam troubleshooting
Only some emails failA plugin overrides headers or FromDisable plugins one at a time, check custom From filters
Works for admin but not customersReceiver rejects some addressesCheck bounce messages and suppression
Sender rejected by relayFrom domain not verifiedVerify the domain with the provider
Duplicate or delayed mailCron or retry settingsCheck WP-Cron and the plugin queue

Hosting and security details that cause surprises

Shared hosts frequently limit outbound connections to specific ports, cap the number of messages per hour, or disable mail() entirely. Ask the host which outbound SMTP ports are allowed, and whether a firewall rule is needed for your relay. If the host blocks all SMTP ports, an HTTPS email API called from a plugin or custom code avoids the issue entirely; see SMTP versus API.

Security matters too. A compromised plugin or a vulnerable contact form can turn your site into a spam source, which damages the reputation of your domain and relay account. Keep WordPress, themes and plugins updated, use a CAPTCHA or honeypot on public forms, and watch your sending volume for unexplained spikes. See signup bot protection. If you suspect abuse, rotate the SMTP credential immediately and review recent activity.

Prevent repeat failures

  • Keep the SMTP password out of version control and rotate it after any staff change.
  • Add a monitor that sends a daily test and alerts if it does not arrive.
  • Use a separate sending identity for system mail and for marketing mail.
  • Handle bounces: stop sending to addresses that hard bounce. See suppression list management.
  • After a host migration, test mail immediately, since firewall rules often differ.

When to use a relay and next steps

If your site sends only a few notifications, an authenticated SMTP connection through a transactional service is enough. If it sends order mail, membership mail or newsletters, plan for monitoring, retries and event handling, and consider separating transactional and marketing streams. For store-specific problems, see WooCommerce emails not sending.

Fix WordPress email for good Send wp_mail through the MigoSMTP relay on port 587 or 465 with authenticated delivery.

Explore the SMTP relay

References and further reading

Frequently asked questions

Why are my WordPress emails not sending?

Most sites use unauthenticated PHP mail(), which hosts often block and receivers distrust. Use authenticated SMTP and DNS authentication.

Does wp_mail returning true mean the email was delivered?

No. It means the message was handed to the mailer. Delivery depends on the relay, the receiver and filters.

Should I use a plugin or code for WordPress SMTP?

Either works. A plugin adds a settings screen and logs; a phpmailer_init hook has fewer dependencies. Keep the password in wp-config.php.

Which port should WordPress use for SMTP?

Use 587 with STARTTLS (SMTPSecure tls) or 465 with implicit TLS (SMTPSecure ssl). Avoid port 25.

Why do WordPress emails go to spam?

Typically the From domain lacks SPF, DKIM or DMARC alignment, or the server IP has weak reputation. Send via authenticated SMTP.

Topics#wordpress#wp_mail#smtp#phpmailer#troubleshooting#php
Was this guide helpful?Your answer helps us improve our documentation.

Start sending in minutes.

Create an account, add your domain and send your first email.

Get started Talk to sales