PHP's mail() function doesn't implement SMTP protocol directly. Instead it relies on sendmail() MTA (SMTP server), or a replacement like postfix or mstmp.
It works fine on Unix as long as MTA installed.
On Windows (from PHP.net manual):
The Windows implementation of mail() differs in many ways from the
Unix implementation. First, it doesn't use a local binary for
composing messages but only operates on direct sockets which means a
MTA is needed listening on a network socket (which can either on the
localhost or a remote machine).
So - the moral of the story - you need to install mail server.
However - if it's for test purpose only - simply get a PHP library that actually implements SMTP protocol and use your regular gmail email address to send emails:
Instead of using PHP's mail() use one of these:
- PHPmailer
- SwiftMailer
- Zend\Mail
These PHP libraries actually implement SMTP protocol so one can easily send emails from any platform, without email server installed on the same machine:
PHPMAILER example:
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "stmp.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "some_email@gmail.com"; // GMAIL username
$mail->Password = "pass111"; // GMAIL password
$mail->SetFrom('some_email@gmail.com', 'My name is slim shady');
$mail->AddReplyTo("some_email@gmail.com","My name is slim shady");
$mail->Subject = "Hey, check out http://www.site.com";
$mail->AltBody = "Hey, check out this new post on www.site.com"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "some_email@gmail.com";
$mail->AddAddress($address, "My name is slim shady");