PHP mail() not working.

I have this code:
<?php $to = "ejer@ejer.rf.gd"; $subject = "This is a test"; $message = "Hi! This is a test ."; $from = "noreply@ejer.rf.gd"; $headers = "From:" . $from; if(mail($to,$subject,$message,$headers)){ echo "Mail Sent."; } ?>
and its not working. I tried other codes from websites like W3 Schools and other simple codes and none of them works. Even when i set the adress to my personal email (This one is on my domain.) it still doesnt send any emails. (It says 'Mail Sent." tho)

Oh, the code didnt quite format well
<?php
$to = "ejer@ejer.rf.gd";
$subject = "This is a test";
$message = "Hi! This is a test .";
$from = "noreply@ejer.rf.gd";
$headers = "From:" . $from;
if(mail($to,$subject,$message,$headers)){
echo "Mail Sent.";
}
?>
Maybe this will be a bit better.

HI

@OxyDac said:
HI
https://infinityfree.net/support/php-mail/

How about this? https://forum.infinityfree.net/discussion/389/mail-not-working (last post from Admin)

now is 2018, not 2016
many people have abused the mail system and because of that it is very restricted.
so do not be surprised when you are unable to send mail.
even if you succeed in send some mails you are never sure does it works or not

please use the recommended one https://infinityfree.net/support/how-to-send-email-with-gmail-smtp/

@datejer said:

@OxyDac said:
HI
https://infinityfree.net/support/php-mail/

How about this? https://forum.infinityfree.net/discussion/389/mail-not-working (last post from Admin)

Did you read the article?

PHP mail is severely restricted on InfinityFree. To prevent spam and other abuse, most messages sent through PHP mail are rejected by the mail system. In practice, this means you cannot use PHP mail on InfinityFree to send your email.

So PHP mail is supported, but it can rarely be used.

Use yandex it’s free,
If you want to get smtp and imap/pop3 access!

But I do not recommend you though because there is an issue on yandex side that hasn’t been fixed since a few years and gmail always marked it as spam due to violations of senders email guidelines.

But if you don’t care and you want imap access, smtp access and want unlimited mail space,
Then this is your choice!