Erro SMTP: não foi possível conectar ao host SMTP

Eu tenho esse código e tudo funciona bem no meu servidor local. O email é enviado sem problemas.

Mas agora passo o conteúdo para o servidor da web e recebo esse erro ...

SMTP Error: Could not connect to SMTP host.

SSL está habilitado no server..correct? Então qual é o problema?

            $mail = new PHPMailer();
            $mail->IsSMTP();
            $mail->SMTPAuth   = true;                  // enable SMTP authentication
            $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
            $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
            $mail->Port       = 465;                   // set the SMTP port
            $mail->Username   = "dnteiro"; // GMAIL username
            $mail->Password   = "xxx";      // GMAIL password

questionAnswers(2)

yourAnswerToTheQuestion