sendmail: not found (PHP mail) Email / SMTP Origin: Network Last updated 4 Nov 2026

PHP: sh: 1: /usr/sbin/sendmail: not found — mail() returns false

PHP's mail() calls the sendmail_path program, but it is not installed or the path in php.ini is wrong.

Exact message you may see sh: 1: /usr/sbin/sendmail: not foundsendmail: not found PHP mailsh: /usr/sbin/sendmail: No such file or directorysendmail_path not foundmail(): Could not execute mail delivery program
Seen on: SMTP PHP Linux

Meaning

mail() does not speak SMTP; it hands the message to a local binary (Sendmail, Postfix, msmtp). In Docker and minimal servers no such binary exists. Install a lightweight MTA such as msmtp or Postfix as a relay, set sendmail_path, or better: use PHPMailer/Symfony Mailer with real SMTP.

Common causes

  • No MTA installed (typical in Docker images)
  • sendmail_path points to a missing binary
  • Binary exists but lacks permissions
  • Chrooted PHP-FPM without access to the binary
  • Disabled mail() by the host

⚡ Quick fix

  1. Install msmtp or Postfix and point sendmail_path at it
  2. Switch to SMTP via PHPMailer or Symfony Mailer
  3. Check phpinfo() for the active sendmail_path

Detailed fix by platform

Linux

  1. which sendmail; php -r 'echo ini_get("sendmail_path");' then apt-get install -y msmtp-mta

Code examples

php.ini with msmtp

ini
sendmail_path = "/usr/bin/msmtp -t"

How to diagnose

  1. Binary — which sendmail finds it?
  2. Path — sendmail_path value?
  3. Container — Minimal image?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

421 4.7.0 Try again later (rate limited) — SMTP: 421 4.7.0 Our system has detected an unusual rate of unsolicited mail originating from your IP address. Mail sent from your IP address has been temporarily rate limited (Email / SMTP)421 4.7.0 Try again l…450 4.7.1 Greylisted, please try again later — SMTP: 450 4.7.1 <user@example.com>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/example.com.html (Email / SMTP)450 4.7.1 Greylisted,…451 4.3.0 Local error in processing — SMTP: 451 4.3.0 Error: queue file write error / 451 Requested action aborted: local error in processing (Email / SMTP)451 4.3.0 Local error…452 4.2.2 Mailbox full / over quota — SMTP: 452 4.2.2 The email account that you tried to reach is over quota (Email / SMTP)452 4.2.2 Mailbox ful…ConnectionRefusedError [Errno 111] (SMTP) — Python: ConnectionRefusedError: [Errno 111] Connection refused — smtplib connect to localhost:25 (Email / SMTP)ConnectionRefusedErro…missing the MySQL extension — WordPress: Your PHP installation appears to be missing the MySQL extension which is required by WordPress (WordPress)missing the MySQL ext…PHP mail — PHP mail() returns false / emails not delivered (PHP)PHP mailPHPMailer: SMTP connect() failed — PHPMailer: SMTP Error: Could not connect to SMTP host. Failed to connect to server (SMTP connect() failed) (Email / SMTP)PHPMailer: SMTP conne…sendmail:…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.