Cant authenticate when trying to send mail with phpMailer over smtp

Cant authenticate when trying to send mail with phpMailer over smtp

This is my code:
$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                              

$mail->isSMTP();                                    
$mail->Host = 'smtp.zoho.com';  
$mail->SMTPAuth = true;
$mail->SMTPDebug = 4;                             
$mail->Username = 'email';               
$mail->Password = 'password';                     
$mail->SMTPSecure = 'tls';                       
$mail->Port = 587;                    

$mail->setFrom('email', 'Mailer');
$mail->addAddress('email to', 'User');
$mail->isHTML(true);            

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}

But when I launch this code it connects to the server but then says the connection failed:

 Auth methods available on the server: LOGIN,PLAIN 2017-03-21 15:14:26 Auth method selected: LOGIN 2017-03-21 15:14:26 CLIENT -> SERVER: AUTH LOGIN 2017-03-21 15:14:26 SMTP -> get_lines(): $data is "" 2017-03-21 15:14:26 SMTP -> get_lines(): $str is "334 VXNlcm5hbWU6 " 2017-03-21 15:14:26 SERVER -> CLIENT: 334 VXNlcm5hbWU6 2017-03-21 15:14:26 CLIENT -> SERVER: aW5mb0B3ZWNtb3JlLm5s 2017-03-21 15:14:26 SMTP -> get_lines(): $data is "" 2017-03-21 15:14:26 SMTP -> get_lines(): $str is "334 UGFzc3dvcmQ6 " 2017-03-21 15:14:26 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 2017-03-21 15:14:26 CLIENT -> SERVER: SmFxdWVzcGVybWVyYW5qbzk= 2017-03-21 15:14:26 SMTP -> get_lines(): $data is "" 2017-03-21 15:14:26 SMTP -> get_lines(): $str is "535 Authentication Failed " 2017-03-21 15:14:26 SERVER -> CLIENT: 535 Authentication Failed 2017-03-21 15:14:26 SMTP ERROR: Password command failed: 535 Authentication Failed 2017-03-21 15:14:26 SMTP Error: Could not authenticate. 2017-03-21 15:14:26 CLIENT -> SERVER: QUIT 2017-03-21 15:14:26 SMTP -> get_lines(): $data is "" 2017-03-21 15:14:26 SMTP -> get_lines(): $str is "221 mx.zohomail.com closing connection " 2017-03-21 15:14:26 SERVER -> CLIENT: 221 mx.zohomail.com closing connection 2017-03-21 15:14:26 Connection: closed 2017-03-21 15:14:26 SMTP connect() failed

I am trying this from my localhost.

Hope you can help me on solving this!