Mail Not Working

I tried sending an email using PHP but it doesn’t work.

if(mail('[email protected]', 'Hello', 'How are you?')){
echo "True";
} else {
echo "False";

I tried sending it to my own email which is clearly not [email protected] but something else. However, it’s not working. Could someone help me with this?

First of all, make sure that your e-mail always includes a valid From: header. PHP mail doesn’t strictly require it, but I haven’t seen any mail servers accept any message which doesn’t have a valid sender.

For the best results, use an e-mail address under the domain of your hosting account as the sender address. The address does not need to have a corresponding mail box or forwarder, but it should not be the same address as the recipient of the message.

$to = "[email protected]";
$subject = "This is a test";
$message = "Hi!  This is a test .";
$from = "[email protected]";
$headers = "From:" . $from;
echo "Mail Sent.";

I tried this and sent it to my actual email but it also didn’t work. I already checked my inbox and spam folder.

Free hosting does not support phpMail() function, I think.

Free hosting does not support phpMail() function, I think.

Free hosting definitely does support PHP mail. However, it should be noted that e-mail delivery is a very tricky thing and ensuring that an e-mail is actually delivered properly can take a lot of frustrating effort.

One possible explanation is that the IP address your website is on is temporarily blocked by your mail provider. Our free servers handle a lot of e-mail, so spam blocks are pretty much guaranteed to appear eventually. Can you please try sending a message to another address on a different e-mail provider as well?