Think I just got it working with the following code
<?php
// PHPMailer classes into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Base files
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
// create object of PHPMailer class with boolean parameter which sets/unsets exception.
$mail = new PHPMailer(true);
try {
//$mail->isSMTP(); // using SMTP protocol
$mail->Host = 'host'; // SMTP host as gmail
$mail->SMTPAuth = true; // enable smtp authentication
$mail->Username = 'emailaddress'; // sender gmail host
$mail->Password = 'password'; // sender gmail host password
$mail->SMTPSecure = 'ssl'; // for encrypted connection
$mail->Port = 587; // port for SMTP
$mail->setFrom('emailaddress', "Business Name"); // sender's email and name
$mail->addAddress('emailaddress', "Business Name"); // receiver's email and name
$mail->Subject = 'New Website Enquiry';
$mail->Body = "A new website enquiry has been made. The enquiry information is below" . "\r\n\r\n" . "Name: " . $_POST["name"] . "\r\n" . "Email: " . $_POST["email"] . "\r\n" . "Subject: " . $_POST["subjectline"] . "\r\n" . "Message: " . $_POST["message"];
$response = $_POST["g-recaptcha-response"];
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = array(
'secret' => 'SECRETKEY',
'response' => $_POST["g-recaptcha-response"]
);
$options = array(
'http' => array (
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$verify = file_get_contents($url, false, $context);
$captcha_success=json_decode($verify);
if ($captcha_success->success==false) {
echo "<p>You are a bot! Go away!</p>";
echo "<br><a href=\"javascript:history.go(-1)\">Go Back To Form</a>";
} else if ($captcha_success->success==true) {
$mail->send();
header('Location:enquiry-confirmation.php');
}
} catch (Exception $e) { // handle error.
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
?>