Thursday 24 January 2013

PHP MAIL() FUNCTION NOT WORKING IN WINDOWS SERVER

When your mail goes to anyone who uses a Windows mail server (comcast, gmail, and maybe aol), the recipients won’t get it.

To test if mail() function exist in your server you can try this few lines of codes.


<?php
if ( function_exists( 'mail') )
   echo 'mail() is enable';
else
   echo 'mail() has been disabled';
?>

If the result above is false/mail is disabled then maybe you need to add the solution I’ve provided below or else of course your mail() code does not formatted correctly

First Steps:


<?php
   // Add this code before mail() function.
  ini_set('SMTP','localhost'); 
   ini_set("sendmail_from", "info@example.com");
?>

Second Steps:


If first steps doesn’t work for you then you need to look a bit in your code header area.
From
$headers .= 'From:  Name <address@example.com>'. "\r\n";
To
$headers .= 'From:  address@example.com'. "\r\n";