phpmailer SMTP connect() failed on localhost
<p>I'm running php5.6 on a localhost using xampp, and I'm trying to send a message using phpmailer, but it gives me this error : SMTP connect() failed.
Here's my code:</p>

<pre><code>require("Photo Gallery/includes/PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer();  
$mail-&gt;IsSMTP();
$mail-&gt;Host = "smtp.gmail.com";
$mail-&gt;Port = 465;
$mail-&gt;SMTPAuth = true;
$mail-&gt;SMTPSecure = 'ssl';
$mail-&gt;Username = "aldemeery@gmail.com";
$mail-&gt;Password = "*********";
$mail-&gt;From     = "aldemeery@gmail.com";
$mail-&gt;AddAddress("aldemeery@gmail.com");
$mail-&gt;Subject  = "Subject";
$mail-&gt;Body     = "Hi!";
if(!$mail-&gt;Send()) {
    echo 'Message was not sent.';
    echo 'Mailer error: ' . $mail-&gt;ErrorInfo;
} else {
    echo 'Message has been sent.';
}
</code></pre>

<p>I know there are tens of questions out there having the same title, but believe me none of them worked for me.Please help, I'v been trying to solve this all day long!</p>