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.
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 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_pathpoints to a missing binary- Binary exists but lacks permissions
- Chrooted PHP-FPM without access to the binary
- Disabled
mail()by the host
⚡ Quick fix
- Install
msmtpor Postfix and pointsendmail_pathat it - Switch to SMTP via PHPMailer or Symfony Mailer
- Check
phpinfo()for the activesendmail_path
Detailed fix by platform
Linux
which sendmail; php -r 'echo ini_get("sendmail_path");'thenapt-get install -y msmtp-mta
Code examples
php.ini with msmtp
sendmail_path = "/usr/bin/msmtp -t"How to diagnose
- Binary — which sendmail finds it?
- Path — sendmail_path value?
- 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:
Similar errors
- 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
- 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
- 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
Most viewed in Email / SMTP
Other ways to find it
Where this error sits
Origin: Network. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 4 Nov 2026