# PHP mail() returns false / emails not delivered

**Code:** `PHP mail` · **Category:** PHP · **Seen on:** PHP

PHP’s mail() function failed or emails never arrive (spam or rejected).

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/php/php-mail-not-sending)
