# WordPress: Mailer Error: Could not instantiate mail function. / wp_mail() failed

**Code:** `WordPress: Could not instantiate mail function` · **Category:** Email / SMTP · **Seen on:** SMTP, WordPress, PHP

WordPress could not send mail through PHP `mail()` because the server cannot hand the message to an MTA or the host disabled the function.

## Meaning

Many hosts block `mail()` or the site has no mail server. The fix is to send through authenticated SMTP using a plugin such as WP Mail SMTP, FluentSMTP or Post SMTP with your provider's credentials, and to publish SPF and DKIM so mail lands in the inbox.

## Common causes

- `mail()` disabled or no sendmail binary
- Host blocks outbound mail from the PHP user
- Wrong From address not matching the domain
- SPF/DKIM missing so mail is rejected after hand-off
- Plugin conflict hooking `wp_mail`

## Quick fix

1. Install an SMTP plugin and use authenticated SMTP or an ESP API
2. Set the From address to one on your domain
3. Use the plugin's email test to see the exact SMTP reply

## Detailed fix by platform

### WordPress

1. `wp eval 'var_dump(wp_mail("you@example.com","Test","Hello"));'` with WP-CLI, and enable debugging in `wp-config.php`: `define('WP_DEBUG_LOG', true);`

## How to diagnose

1. **Function** — mail() available?
2. **Plugin** — SMTP configured?
3. **DNS** — SPF/DKIM set?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/email/wordpress-could-not-instantiate-mail-function)
