Phpmailer issues

can anyone give me some help with phpmailer, please?

I have followed guides and the phpmailer documentation, my host has correctly configured my server to be able to send emails using PHP mailer and SMTP and now I'm stuck on what to try next. My host has even set up a mailbox on my server and give me the details to use with phpmailer and it still doesn't work.

Using phpmailer v6.0.7 by the way. It used to work with 5.2 but because of security issues with 5.2, I'd rather not use it.

My phpmailer script (contact.php) with passwords and emails address removed for the sake of the purpose of this post.

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';


if(isset($_POST['send'])){
    $name = $_POST['name'];
    $surname = $_POST['surname'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $message = $_POST['message'];

// Instantiation and passing `true` enables exception

$mail = new PHPMailer(true);

try {
    //Server settings
    $mail->SMTPDebug = 3;                                       // Enable 
    verbose debug output
    $mail->isSMTP();                                            // Set mailer to use SMTP
    $mail->host       = "smtp.office365.com";  
    $mail->SMTPAuth   = true;                                  
    $mail->username   = "Xxxx";                    
    $mail->password   = "xxxx";                               
    $mail->SMTPSecure = "TLS";                                  
    $mail->port       = "xxx";                                    

    $mail->setFrom($email, $name, $surname);
    $mail->addAddress('xxx.org.uk', 'xx');     
    $mail->addReplyTo('xxx.org.uk', 'xx');

    $mail->isHTML(true);                                  
    $mail->Subject = 'New Message - Website contact form';
    $mail->Body = $message;


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

And this is the contact form I am using

<html>
 <form id="contact-form" method="post" action="contact.php" role="form">
    <div class="messages"></div>
    <div class="controls">
    <div class="row">
       <div class="col-md-6">
          <div class="form-group">
            <label for="form_name">Firstname</label>
            <input id="form_name" type="text" name="name" class="form- 
               control" placeholder="Please enter your firstname" 
               required="required" data-error="Firstname is required.">
          <div class="help-block with-errors"></div>
       </div>
    </div>
        <div class="col-md-6">
           <div class="form-group">
            <label for="form_lastname">Lastname</label>
              <input id="form_lastname" type="text" name="surname" 
              class="form-control" placeholder="Please enter your lastname" 
              required="required" data-error="Lastname is required.">
         <div class="help-block with-errors"></div>
       </div>
     </div>
   </div>
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label for="form_email">Email</label>
              <input id="form_email" type="email" name="email" class="form- 
              control" placeholder="Please enter your email" 
              required="required" data-error="Valid email is required.">
       <div class="help-block with-errors"></div>
      </div>
     </div>
        <div class="col-md-6">
          <div class="form-group">
            <label for="form_need">Phone</label>
              <input id="form_email" type="text" name="phone" class="form- 
                control" placeholder="Please enter your contacr number">
            <div class="help-block with-errors"></div>
        </div>
      </div>
    </div>
       <div class="row">
         <div class="col-md-12">
           <div class="form-group">
             <label for="form_message">Message</label>
               <textarea id="form_message" name="message" class="form- 
                 control" placeholder="Message for us" rows="4" 
                required="required" data-error="Please, leave us a message."> 
               </textarea>
        <div class="help-block with-errors"></div>
      </div>
    </div>
       <div class="col-md-12 mb-3">
         <input type="submit" name="send" class="btn btn-primary" value="Send Message">
          </div>
         </div>
        </div>
      </div>
     </form>
</html>

The error I am getting is

2019-09-11 17:44:52 SMTP ERROR: Failed to connect to server: (0) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent. Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

I know this error is referred to as a host problem, but as I said they have configured the server and even set a mailbox on the server to send emails through which doesn't work either.