I don’t really get what you are trying to do. The comment says that SmtpConnect()
does what you want and throws an exception - so you should see any error that occurs directly on screen, or in the error.log of your webserver. Two lines later you are using this function again, but that wont run if the first one already throw an error. And you are not even outputting any information from catched exception. Also the documentation tells you something about error information
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}