Take 22% off yearly plans. Use code "POWERUP22" at checkout. See plans

WordPress wp_mail() Explained

Understand what WordPress wp_mail does, how plugins change its transport and why its return value does not confirm receipt.

Cover image for WordPress wp_mail() Explained

wp_mail is WordPress’s function for sending an email from application code. A plugin can call it when a form is submitted, an order changes state or another event requires a notification.

The function gives the caller a common interface. The configured mail path determines how the message is submitted. That is why an SMTP plugin can change sending behavior without requiring every form or store plugin to rewrite its notification code.

A successful result is limited to the observed sending operation. The WordPress function reference explicitly distinguishes that result from recipient receipt.

A silent animation of where wp_mail() sends a message, about 14 seconds. WordPress sends everything through wp_mail(). By default that uses PHP mail(), which only works where the host delivers. With PressedMail SMTP it sends through the SMTP account you set up, for every plugin and theme. Your PressedMail inboxes use their own servers either way.

Understand the call before changing transport

A basic call supplies a recipient, a subject and a message. Optional arguments can provide headers and attachments.

The caller decides when the notification should exist and what it should say. The mail route handles its submission. If the application never calls the route because the notification is disabled or an event did not occur, SMTP settings cannot repair that missing trigger.

This separation is useful when debugging. WordPress email triage starts with generation, then follows transport and recipient evidence.

The function itself is also different from an inbox client. Calling it does not retrieve existing messages or create a mailbox interface.

A minimal controlled example

The following PHP belongs in an authorized testing context where WordPress is already loaded. Replace the example recipient with an address you control before running it.

$recipient = 'recipient@example.com';

if ( ! is_email( $recipient ) ) {
    throw new InvalidArgumentException( 'Use a valid test recipient.' );
}

$sent = wp_mail(
    $recipient,
    'WordPress mail check',
    'A plain-text test from the configured WordPress mail route.'
);

This example submits a real message when executed. Run it once through an appropriate developer or administrator test workflow. Do not attach it to every page load or expose an unauthenticated public send endpoint.

Inspect the boolean result, then check the receiving mailbox. A true result is not a read receipt. Keep the test subject distinct from real notifications so you can correlate the attempt with a record.

For a UI-driven test instead of PHP, use the configured sender’s test-email control described in SMTP testing.

Keep external input outside the trusted part

Real notification code often receives user-supplied values. Validate the recipient and any fields used to build the message according to the application’s requirements.

Do not concatenate raw form input into mail headers. A form email field belongs in a controlled, validated mapping. The contact-form SMTP guide explains the difference between an authorized From address and a visitor’s Reply-To address.

An email function call is not permission to send to arbitrary destinations. A public form still needs its own validation, access decisions and abuse controls. Those belong to the form or application that triggers the message.

Likewise, do not put SMTP credentials into the example call. The site’s configured route should own its transport settings.

How an SMTP plugin changes the path

WordPress initializes PHPMailer and exposes the phpmailer_init hook. A routing plugin can configure that instance for the chosen transport.

PressedMail uses this path for its WordPress SMTP server. It adds its callbacks to wp_mail, phpmailer_init, wp_mail_from and wp_mail_from_name, all at the last priority, so its settings usually have the final say over the transport and the sender. It listens to wp_mail_succeeded and wp_mail_failed to fill its delivery log. Free provides one outgoing server. Paid builds add multiple servers and sender-based routing.

The caller can continue using wp_mail while that configured route changes. The mailbox connection used for reading email remains a separate configuration.

The Default SMTP tab of WordPress Email with five areas numbered

  1. The tabs. Pro shows SMTP Accounts, Default SMTP and System Emails. Free shows System Emails and Mail servers.
  2. Add SMTP account. The Free button reads Add mail server.
  3. WordPress default. This sends through PHP mail().
  4. PressedMail SMTP. Sends what WordPress, a plugin or a theme sends through the server you set up here. It stays unavailable until you add one.
  5. A note that your PressedMail inboxes are not affected either way.

The screenshot is from a paid build. The choice on this screen is the route that every wp_mail() call takes.

The System Emails tab shows the other half of the picture. WordPress sends many kinds of message, and each row is one of them.

The System Emails table with four areas numbered

  1. An email WordPress sends, grouped for example under Accounts and Passwords.
  2. Template. Keep the WordPress default or pick a template to change the wording.
  3. SMTP connection. Choose which server sends that message, or leave it on the default.
  4. Sender. Use the server default address or pick another.

The screenshot is from a paid build.

Configure one owner for this route. Several plugins changing the same mailer or sender can create outcomes that are difficult to reason about, especially when a form supplies an explicit From address.

Sending WordPress email through SMTP covers the administrator setup. PHP mail versus SMTP compares submission arrangements without changing the application-level purpose of the call.

Read failures without exposing message contents

WordPress exposes a wp_mail_failed hook when it catches the relevant PHPMailer exception. The error object can include message data.

That makes dumping the whole object into a public page or an unrestricted log a poor debugging habit. A password-reset message can contain an active credential, and other notifications may include personal information.

Record only the information needed to identify the failure. Prefer the established metadata log when it supplies the required error and correlation details.

PressedMail’s WordPress log retains limited recipient information, subject, sender, connection and outcome metadata. It excludes message bodies, raw headers and attachments. The logging guide explains retention and the limits of that record.

The WordPress delivery log with five areas numbered

  1. Refresh. Reloads the log.
  2. Clear log. Removes the history after you confirm.
  3. Subject. Match an entry by its subject.
  4. Server. Names the connection that sent the message. “Not sent by PressedMail” means it went out by PHP mail() or another plugin’s transport, and PressedMail only recorded it.
  5. Result. Whether the send was observed as sent or failed.

The rows come from a seeded test site. The log never stores the message body, headers or attachments.

Plain text, HTML and attachments

Keep an initial test plain text. That avoids confusing transport with formatting.

HTML messages need an appropriate content type. If application code changes a global content-type filter, scope and remove that change correctly so later unrelated messages are not affected. Follow the current WordPress reference for the version you support rather than copying an old global snippet into a theme.

Attachments also add their own failure possibilities, including unavailable files and provider size restrictions. Start with a small controlled file only after plain messages work.

A successful plain-text test does not prove that every template or attachment behaves correctly. Test the actual message format the application will send.

Some integrations bypass wp_mail

A plugin may call a sending provider’s API directly or use its own mail client. In that case, the site’s WordPress SMTP settings may not control its message.

Before changing configuration, identify the actual sending path. A working wp_mail test and a failing API notification can coexist because they use different credentials, code and providers.

The same applies to evidence: a WordPress logger may not see an independent API event. Checking whether mail was sent explains how to avoid claiming more than the available record proves.

Frequently asked questions

Is wp_mail the same as PHP mail?

It is WordPress’s application-level mail function. The underlying configured transport may use the default mail path or be changed by a plugin.

Does true mean the recipient received the message?

No. Check the recipient or provider evidence separately.

Must each plugin contain SMTP credentials?

No. Applications using the common WordPress route can rely on its configured transport. Keep credentials in the route’s supported configuration.

Why does my form fail when the PHP example works?

The form may have different headers, recipients, trigger conditions or an independent sending integration. Test and inspect its actual path.

Should I edit WordPress core to change sending?

No. Use the supported configuration and extension hooks. Core edits are not needed for an ordinary SMTP setup.

Manage your email inside WordPress

PressedMail Free adds an email client directly to your WordPress dashboard. Connect a compatible IMAP/SMTP mailbox, read and send mail, organize messages, and configure WordPress SMTP.

Download PressedMail Free →

Newsletter

Get useful PressedMail updates.

New releases, setup guidance, and practical ways to handle email in WordPress.

Occasional PressedMail email. Unsubscribe whenever you like.

Choose the plan that fits your WordPress sites.

Paid plans include unlimited accounts and users. Compare Premium and Ultimate features, then choose the site count you need.

Yearly plans are priced by number of sites. Lifetime is a one-time payment covering up to 100 sites.

Starter

For one site

$39/ year
1 Website
  • All current and future Premium features
  • Unlimited email accounts
  • Contacts, calendar, and scheduled email rules
  • Templates, blocks, and signup forms
  • AI tools and phishing detection
  • Layouts, themes, and workspace controls
  • Licensed updates and priority support
  • 10,000 PressedMail AI credits a yearLimited time
Most Popular

Premium

For multiple sites

$69/ year
10 Websites
  • All current and future Premium features
  • Unlimited email accounts
  • Contacts, calendar, and scheduled email rules
  • Templates, blocks, and signup forms
  • AI tools and phishing detection
  • Layouts, themes, and workspace controls
  • Licensed updates and priority support
  • 25,000 PressedMail AI credits a yearLimited time
All Features

Ultimate

For agencies

$129/ year
100 Websites
  • Everything in Premium, plus:
  • Campaigns and shared templates
  • Share inboxes, calendars and contact lists
  • White labelling with a brand theme
  • 50,000 PressedMail AI credits a yearLimited time

What customers say after bringing email into WordPress.

Using PressedMail in your own work? Submit a testimonial

I save hours & it’s easy to use

I have a lot of email accounts, and it’s annoying to manage them through different providers. I needed something better than what was out there, so I built it. I spent the better part of two years making PressedMail the plugin I wanted to use every day, and now I get to share it with everyone else. I added my accounts, automated the cleanup of over 3000 emails, and it’s saved me hours of work.

Robert H. AlexanderFounder - CurbSoftwareCreator of PressedMail

Email Swiss Army Knife

We use PressedMail as a value added service for clients and potential clients as a feature of our agency’s offering helping put us ahead of competition. We love the white-labelling feature, automation, and security controls. It also replaces several of the other plugins we used to use and it’s like a small CRM.

Gene Piki
FAQ

Common questions

Free version

Start with one inbox. Free.

One mailbox for one user, a rich-text composer, custom folders, unlimited email rules, one signature, two themes and one layout. Contacts, calendar, scheduling and AI require a paid plan.

1 account · 1 user · 2 themes · unlimited rules
Roadmap

See what is coming next.

Follow planned work, current progress, and recently completed features.

  1. In Progress

    WooCommerce Integration

    Connect PressedMail with WooCommerce so order, customer, and store email flows stay tied to the right orders and customer records inside WordPress.

  2. Planned

    Calendar Sync with External Providers

    Planned. Today calendars and events live in WordPress and do not sync with any outside provider. Two-way sync with Google Calendar, Outlook, iCloud and CalDAV-compatible services is on the roadmap.

  3. Planned

    Dedicated Support

    A higher-touch support channel beyond the current paid Priority Email Support entitlement.

Bring your working inbox into WordPress.

Compare Premium and Ultimate features, then choose a paid plan for the number of WordPress sites you manage.

WordPress wp_mail() Explained