PHP mail 🐘 PHP

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

  1. Send via authenticated SMTP (PHPMailer/Symfony Mailer) or a transactional email API
  2. Use a From address on your own domain
  3. Add SPF/DKIM records

Detailed fix by platform

PHP

  1. Check sendmail_path in phpinfo() and the MTA log (/var/log/mail.log)

How to diagnose

  1. Return — Does mail() return false?
  2. Logs — What does the mail log say?
  3. 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.