You don’t have to have a domain name to test php’s mail().
You can use a free local web server like XAMPP. The headers in your mail() must include a From: header which needs to be a real email address on the mail server set in your SMTP parameter in your php.ini. You can set the SMTP parameter value using ini_set() in your php script if you don’t have access to your php.ini.
You also must have SMTP enabled on on your local or “real” web server for mail() to work.
//of course sanitize everything that is received for user input
//sanitize $_POST
//setup to, message and subject
// make sure $_POST['email'] is only one email address
$email= $_POST['email'];
$additional_header = "From: $email\\r\
"
$t = mail($to, $subject, $message, $additional_header);
if($t){
echo 'sent';
}else{
echo 'failed';
}
If you try to send mail from your localhost, beware that it will get caught in every spam filter there is. Just be aware that you mailer may work but you may never get any mail.
Since sending email from localhost is considered spammy and in most cases will not even get into the spam box. Anyway thats what happened to me. In the good old days it used to work.