无法在使用Gmail SMTP配置的localhost XAMPP上发送邮件

I am unable to send mails on localhost.

Following are the Gmail settings in XAMPP >> php.ini

[mail function]

; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
 SMTP = smtp.gmail.com
 smtp_port = 465
 username = user@gmail.com
 password = pass

; For Win32 only.
; http://php.net/sendmail-from
 sendmail_from = user@gmail.com

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.  
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
; sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

Following is the mail code:

<?php
$headers = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$headers .= 'From: user@gmail.com' . "
";

$result = mail('user@gmail.com', 'Test Mail', 'Please ignore! This is a test message.', $headers);
print_r($result); die;
?>

In $result I am getting 1.