Jump to content

Mail Function Not working - Deployed in windows server


perplexeddev

Recommended Posts

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{
$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("<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.
 

Hi,

 

@ DENNO020 : Feel honoured, he came here for help.

 

 

Divide and conquer...

 

Code looks fine, though I am tired and had a few to many drinks, lets assume all is ok, since no other errors came up... Give this a try:

  1. Check if your SMTP is setup (Reference: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e4cf06f5-9a36-474b-ba78-3f287a2b88f2.mspx?mfr=true),
  2. Check Port 25 is open on the server,
  3. Check your php.ini is setup to these configurations: http://www.php.net/manual/en/mail.configuration.php.

Note: If you are using a home computer for the server, beware that some ISP's block port 25, alternative ports can be used default ports: 25 or 587 (reference: http://www.arclab.com/en/amlc/list-of-smtp-and-pop3-servers-mailserver-list.html)

 

See how you go, if none of above helps, please let us know, we are always happy to help.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.