I think the issue is the combination of the port and the security. If $mail->SMTPSecure = 'ssl'
, then the port number you should use is probably 465
. If you use port 587
, it should be combined with $mail->SMTPSecure = 'tls'
.
You can use port 465 or port 587, but normally they use different encryption. And your configuration should reflect that.