I am new to PHP, I have a website done in HTML and PHP.In my site,I have a form that sends mail.
My PHP code is
?php
try{
$to = 'test@test.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: noreply@test.com' . "\r\n" .
'Reply-To: test@test.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers))
{
echo("<p>Email successfully sent!</p>");
}
else{
echo("<p> Email delivery failed </p>");
}
}
catch(Exception $e){
echo 'Caught Exception', $e->getMessage(), "\n";
}
?>
I am using valid to and from addresses, but i always get the message "Email delivery Failed" and I dont get the email.
Also I have deployed my website in windows server, are there any configurations to be done on the server.
Thanks for your help in advance.