# mail (PHP) doesn’t work on subdomain

**URL:** <https://community.ovhcloud.com/t/mail-php-ne-fonctione-pas-sur-sous-domaine/53920>\
**Category:** E-mails\
**Tags:** hébergement-web\
**Created:** [September 15, 2026, 8:31am UTC](https://community.ovhcloud.com/t/mail-php-ne-fonctione-pas-sur-sous-domaine/53920 "2026-09-15T08:31:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Driver](https://community.ovhcloud.com/letter_avatar/driver/32/6_22734026db12803ebb3e059622ac3534.png) [@Driver](https://community.ovhcloud.com/u/Driver)\
**Post date:** [September 15, 2026, 8:31am UTC](https://community.ovhcloud.com/t/mail-php-ne-fonctione-pas-sur-sous-domaine/53920/1 "2026-09-15T08:31:24Z")

</div>

Hello,  
My mail scripts (PHP) work on my main domain and on several subdomains, but on one subdomain they don’t work.  
I ran a test with a simple script without success

> $to = "[destinataire@destinataire.com](mailto:destinataire@destinataire.com)";  
> $subject = "Test mail PHP";  
> $content = "Le contenu du mail ";  
> $headers = "From: Website [contact@monsousdomaine.com](mailto:contact@monsousdomaine.com)\r\nReply-To: [contact@monsousdomaine.com](mailto:contact@monsousdomaine.com)";  
> if (mail($to, $subject, $content, $headers)){  
> echo "Le mail a été envoyé avec succès";}  
> else  
> echo "Le mail n'a pas été envoyé";

I get the message "The mail was sent successfully" but the mail is not delivered.  
Any idea why?

I created ticket CS16712553

---

<div class="post-metadata">

**Author:** ![sturpin](https://community.ovhcloud.com/user_avatar/community.ovhcloud.com/sturpin/32/30025_2.png) [@sturpin](https://community.ovhcloud.com/u/sturpin)\
**Post date:** [September 15, 2026, 8:48am UTC](https://community.ovhcloud.com/t/mail-php-ne-fonctione-pas-sur-sous-domaine/53920/2 "2026-09-15T08:48:00Z")

</div>

Hi @Driver

I recommend dropping mail() and using PHPMailer with SMTP authentication.

Let me know, best regards.  
Sergio Turpín

---

<div class="post-metadata">

**Author:** ![Driver](https://community.ovhcloud.com/letter_avatar/driver/32/6_22734026db12803ebb3e059622ac3534.png) [@Driver](https://community.ovhcloud.com/u/Driver)\
**Post date:** [September 23, 2026, 10:03am UTC](https://community.ovhcloud.com/t/mail-php-ne-fonctione-pas-sur-sous-domaine/53920/3 "2026-09-23T10:03:29Z")

</div>

Hello,  
Based on your answer on another topic, I replaced the From address with one from the hosting, and now it works, but that's not satisfactory because it would mean that domains hosted on a multisite setup could not/anymore use the mail function.
