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.
I tried all the steps mentioned above but I still get the message "Email delivery Failed".
I saw 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 for your help in advance.
PHP Mail Function Not working - Deployed in windows server
Moderator: General Moderators
-
perplexeddev
- Forum Newbie
- Posts: 1
- Joined: Tue Apr 22, 2014 4:09 pm
Re: PHP Mail Function Not working - Deployed in windows serv
Do you have a mail server configured? Windows doesn't ship with one, so you'll either need to install one, or configure PHP to use an external SMTP server.