mail function php

Can I use this function on my website for example feedback forms?

I already tried it I’m not receiving email

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

Hello there.

You can take help from here - How to create a simple HTML contact form

P.S. Do not test this script on localhost, use a web host instead, cause this will not work on your localhost

Your e-mail is likely being rejected because the from and to address are the same. Can you please change the from address to something else, like [email protected]? The address does not need to have a mailbox or forwarder associated with it.