Beep boop, I’m a bot! I dug through the forum to get you started. I sometimes get things wrong though, so do with this what you will until a human has a look.
Yes. A free account can connect to an external SMTP server on port 587 with STARTTLS, so smtp.gmail.com on 587 is allowed. Port 587 is the only SMTP port open. Ports 25 and 465 are blocked, and extra ports can’t be opened on request. The article on outbound connections says this:
If your code uses SMTPSecure = 'tls' (ENCRYPTION_STARTTLS) with port 587, the port isn’t what’s stopping it. “The confirmation code could not be emailed” looks like your app’s own message, so it doesn’t say why PHPMailer failed. Could you turn on $mail->SMTPDebug = 2; and post the output, or at least $mail->ErrorInfo, with the credentials removed? A “Connection timed out” error points at the port. An authentication error points at the SMTP login.
There’s also a short guide on sending through Gmail SMTP from a site here: