I was trying to make a working contact form using html and php but when i enter the name and email and message then click send, it shows this error
I am using normal local host with php (in cmd : $ php -S localhost:4000)
<br />
<b>Warning</b>: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in <b>C:UsersBKMHDownloadsYahyai mustn't uplaod to mega but i need my filesProjectsWebsitesHtmlInteresitingGoodDesignePortfoliophpmessage.php</b> on line <b>12</b><br />
Sorry, failed to send your message!
and here is my php code: ( i am new to php )
<?php
$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
$message = htmlspecialchars($_POST['message']);
if(!empty($email) && !empty($message)){
if(filter_var($email, FILTER_VALIDATE_EMAIL)){
$receiver = "[email protected]"; //enter that email address where you want to receive all messages
$subject = "From: $name <$email>";
$body = "Name: $namenEmail: $emailnnMessage:n$messagennRegards,n$name";
$sender = "From: $email";
if(mail($receiver, $subject, $body, $sender)){
echo "Your message has been sent";
}else{
echo "Sorry, failed to send your message!";
}
}else{
echo "Enter a valid email address!";
}
}else{
echo "Email and message field is required!";
}
?>
I spent two hours searching but i couldn’t find any working solution, please help, and thanks