# PHP mail not working

**URL:** <https://forum.infinityfree.com/t/php-mail-not-working/42536>\
**Category:** Hosting Support\
**Created:** [March 7, 2021, 11:41am UTC](https://forum.infinityfree.com/t/php-mail-not-working/42536 "2021-03-07T11:41:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon54237165](https://forum.infinityfree.com/letter_avatar/anon54237165/32/6_449c533f586939b6e5f246632a46421f.png) [@anon54237165](https://forum.infinityfree.com/u/anon54237165)\
**Post date:** [March 7, 2021, 11:41am UTC](https://forum.infinityfree.com/t/php-mail-not-working/42536/1 "2021-03-07T11:41:47Z")

</div>

[https://musafir.cf](https://musafir.cf)

Hello,

I am working on a support system for one of my websites.

I am noticing that PHP’s mail() function does not work when attempting to send an email. Can this be fixed? Thanks.

---

<div class="post-metadata">

**Author:** ![Oxy](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/oxy/32/37989_2.png) [@Oxy](https://forum.infinityfree.com/u/Oxy)\
**Post date:** [March 7, 2021, 11:54am UTC](https://forum.infinityfree.com/t/php-mail-not-working/42536/2 "2021-03-07T11:54:40Z")

</div>

Hi and welcome to the forum

> **[Sending email from your website (PHP mail)](https://forum.infinityfree.com/docs?topic=49242)**
>
> The most common way to send email from your website is by using the PHP mail() function. PHP mail() is an easy to use email system built into the PHP programming language. It’s the default setting for almost all applications. However, PHP mail is...

> **[How to send email with Gmail SMTP](https://forum.infinityfree.com/docs?topic=49239)**
>
> Outgoing email with PHP mail() is heavily restricted on InfinityFree. Fortunately, you can still whatever email you want using an external email service. There are many external email providers to choose from. InfinityFree doesn’t restrict sending...

P.S. you can enable debugging in phpmailer (if needed)

> **[SMTP Debugging](https://github.com/PHPMailer/PHPMailer/wiki/SMTP-Debugging)**
>
> The classic email sending library for PHP. Contribute to PHPMailer/PHPMailer development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Oxy](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/oxy/32/37989_2.png) [@Oxy](https://forum.infinityfree.com/u/Oxy)\
**Post date:** [March 7, 2021, 12:13pm UTC](https://forum.infinityfree.com/t/php-mail-not-working/42536/3 "2021-03-07T12:13:28Z")

</div>

@anon54237165

and PATH is not valid for you either

because your form is here [https://musafir.cf/p/contact\_us](https://musafir.cf/p/contact_us) (that dir “/p/”)

and button `send message` wants to give all parameters  
here [https://musafir.cf/p/inc/sendemail.php](https://musafir.cf/p/inc/sendemail.php) (error 404)

but your` sendemail.php` is actually here [https://musafir.cf/inc/sendemail.php](https://musafir.cf/inc/sendemail.php) (no extra dir “p”)

* * *

but you should definitely use a FORM from our template above that has a reCAPTCHA and does additional checking to see if everything needed is typed on all fields (less spam in your inbox)

---

<div class="post-metadata">

**Author:** ![anon54237165](https://forum.infinityfree.com/letter_avatar/anon54237165/32/6_449c533f586939b6e5f246632a46421f.png) [@anon54237165](https://forum.infinityfree.com/u/anon54237165)\
**Post date:** [March 7, 2021, 12:20pm UTC](https://forum.infinityfree.com/t/php-mail-not-working/42536/4 "2021-03-07T12:20:17Z")

</div>

[https://musafir.cf/mailer.php](https://musafir.cf/mailer.php)

I am using PHPMailer on this page but it just gives 502 error

---

<div class="post-metadata">

**Author:** ![Oxy](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/oxy/32/37989_2.png) [@Oxy](https://forum.infinityfree.com/u/Oxy)\
**Post date:** [March 7, 2021, 12:24pm UTC](https://forum.infinityfree.com/t/php-mail-not-working/42536/5 "2021-03-07T12:24:37Z")

</div>

> [@PHPMailer doesn't work](https://forum.infinityfree.com/t/phpmailer-doesnt-work/14545/2):
>
> I checked your code, and I think the issue is caused by an include loop. In the code you shared, you have the line require ("PHPMailer.php");. However, I have checked this file “PHPMailer.php”, but that file also contains a script like what you’ve shared here. Can you please make sure the file PHPMailer.php contains the actual PHPMailer library, and see if you can have another script which uses that library?

have you tried this one from this location

> **[Releases · InfinityFreeHosting/contactform](https://github.com/InfinityFreeHosting/contactform/releases)**
>
> Simple contact form with PHPMailer. Contribute to InfinityFreeHosting/contactform development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![anon54237165](https://forum.infinityfree.com/letter_avatar/anon54237165/32/6_449c533f586939b6e5f246632a46421f.png) [@anon54237165](https://forum.infinityfree.com/u/anon54237165)\
**Post date:** [March 7, 2021, 1:34pm UTC](https://forum.infinityfree.com/t/php-mail-not-working/42536/6 "2021-03-07T13:34:07Z")

</div>

Thanks, man. I have installed the InfinityFree contact form and it has solved my problem Thanks once again.

---

<div class="post-metadata">

**Author:** ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)\
**Post date:** [March 22, 2021, 1:34pm UTC](https://forum.infinityfree.com/t/php-mail-not-working/42536/7 "2021-03-22T13:34:15Z")

</div>

Closed on March 22, 2021, 1:34pm UTC

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
