PHP Mail Function Not working - Deployed in windows server

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 = ‘[email protected]’;
$subject = ‘the subject’;
$message = ‘hello’;
$headers = ‘From: [email protected]’ . “\r\n” .
‘Reply-To: [email protected]’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();
if(mail($to, $subject, $message, $headers))
{
echo(“

Email successfully sent!

”);
}
else{
echo("

Email delivery failed

");
}
}
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.

I get the following error in PHP Log:
PHP Warning : mail(): SMTP server response: 530 5.7.1 Client was not authenticated in on line 10.
Line 10 is if(mail($to, $subject, $message, $headers)) in my PHP file.

Thanks in advance

Did you check your php.ini for mail options?
Do you have a mail server installed on your system?
Do you have sendmail program installed?

Sponsor our Newsletter | Privacy Policy | Terms of Service