I recently had a problem trying to send email using the PHP Mail function on Windows Server and it appears that PHPmail() function don’t work perfectly in Windows mail servers. So, 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
1
2
3
4
5
6
<?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
1
2
3
4
<?php
   // Add this code before mail() function.
   ini_set(“sendmail_from”, );
?>

Second Steps:

If first steps doesn’t work for you then you need to look a bit in your code header area.
XHTML
1
2
3
4
From
$headers .= ‘From:  Name <address@sutanaryan.com>’. “\r\n”;
To
$headers .= ‘From:  address@sutanaryan.com’. “\r\n”;
You need to remove Friendly Name in your headers to work as PHP running on Windows doesn’t parse these headers correctly.
That’s it, so you can now send email to both linux and windows server, if you have other solution you can share it below.

0 comments:

Post a Comment

 
Top