Can't send mail using PHPMailer SMTP

Good afternoon, I am trying to set up sending mail from the server using PHPMailer.

If I use the data to set up sending mail that Hostia offers me in the “Mail->accounts” section, I get the following error “Mailer Error: SMTP connect() failed”. But if I write in SMTP->host I get the error “smtp error: could not authenticate”. I don’t understand a bit what I need to do to make it work. Because I’m strictly following the instructions, but in the end it still doesn’t work.

This is my test code

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;

//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that

require 'vendor/autoload.php';

$mail = new PHPMailer();
$mail->SMTPDebug = 4;
$mail->SMTPOptions = array(
       'ssl' => array(
                'verify_peer' => false,
                'verify_peer_name' => false,
                'allow_self_signed' => true
$mail->Host = '';
$mail->Port = 587;//also tried 465 and 25
$mail->SMTPAuth = true;
$mail->AuthType = 'LOGIN';
$mail->Username = '[email protected]';
$mail->Password = 'pass';
$mail->setFrom('[email protected]', 'First Last');
$mail->addReplyTo('[email protected]', 'First Last');
$mail->addAddress('[email protected]', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';
$mail->Body = 'Hello, this is my message.';
$mail->AltBody = 'This is a plain-text message body';

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