PHP mail() returns false / emails not delivered
PHP’s mail() function failed or emails never arrive (spam or rejected).
Seen on:
PHP
Meaning
mail() only hands the message to the local MTA (sendmail/postfix). Many hosts disable it, and messages without SPF/DKIM from a matching domain are rejected or land in spam.
Common causes
- No local mail transfer agent
- Host blocks mail()
- From address not on your domain
- Missing SPF/DKIM/DMARC records
⚡ Quick fix
- Send via authenticated SMTP (PHPMailer/Symfony Mailer) or a transactional email API
- Use a From address on your own domain
- Add SPF/DKIM records
Detailed fix by platform
PHP
- Check
sendmail_pathin phpinfo() and the MTA log (/var/log/mail.log)
How to diagnose
- Return — Does mail() return false?
- Logs — What does the mail log say?
- DNS — SPF/DKIM present?
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026