PHPMailer XAMPP SMTP身份验证失败

I'm trying to use PHPMailer to send e-mail from my local virtual host on XAMPP with the code below. I have enabled extension=php_openssl.dll in php.ini, still I get the error messages below. Anyone knows why?

require_once 'PHPMailerAutoload.php';
require_once 'class.phpmailer.php';
require_once 'class.smtp.php';

$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Username = "xxx";
$mail->Password = "xxx";

$email = "xxx@gmail.com";
$name = "Test";
$email_from = "xxx@gmail.com";
$name_from = "Test";

$mail->AddAddress($email, $name);
$mail->SetFrom($email_from, $name_from);
$mail->Subject = "My Subject";
$mail->Body = "Mail contents";

try{
    $mail->Send();
    echo "Success!";
} catch(Exception $e){
    echo "Fail - " . $mail->ErrorInfo;
}

Error output: SMTP ERROR: Password command failed: 534-5.7.14 SMTP Error: Could not authenticate.