Making mail() function of PHP work under windows os
mail() is a useful function in PHP for sending mails, but many developers face problems in making mail() work properly on Windows.
In the section [mail function] in the php.ini file, you’ll find three settings:
SMTP, sendmail_from, and sendmail_path.
If your server runs on a Windows machine, you’ll have to set the SMTP option to point to your SMTP server for sending mail using PHP.
So, we must understand that PHP must have the address of some SMTP server where it would deliver the mail to be sent and that is all PHP can actually do.
So, we need to set SMTP to the SMTP server and the sendmail_from option to the required email address.
Now if we want to use localhost as the SMTP server, we must have some SMTP server running on our system, simple isn’t it? So we can download and install hMailServer from www.hmailserver.com/ for serving our purpose.
After installing the mail server make sure that you switch off SMTP authentication for connections coming from localhost / 127.0.0.1 in hMailServer for your mail() function to work.
And this is how [mail function] part of your php.ini should look:
[mail function]
; Setup for Windows systems
SMTP = localhost
sendmail_from = me@mydomain.tld

