I have problem with PhpMailer function on webserver

I got this error Message could not be sent. Mailer Error: SMTP Error: Could not authenticate
Here is my code

$mail = new PHPMailer(true);     
try {
$mail->IsSMTP(); 
$mail->Host = 'smtp.gmail.com';  
$mail->SMTPAuth = true; 
$mail->SMTPDebug = 2;
$mail->CharSet = "utf-8";
$mail->Username = "[email protected]";    
$mail->Password = "***********";                      
$mail->SMTPSecure = 'ssl';                      
$mail->Port = 465;                                 
$mail->setFrom('[email protected]', ' ');
$mail->addAddress($email);
$mail->addReplyTo('[email protected]');
$result='';
$mail->isHTML(true);                         
$mail->Subject = 'Your Password Reset Link';
$mail->Body    =  "Body";
$mail->AltBody =  "Body";
if($mail->send()){
$result="success";
echo "Success";
}
// Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
// Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
Sponsor our Newsletter | Privacy Policy | Terms of Service