I have tried to connect to mit private as well to my google apps for work inbox via IMAP using the Horde_Imap_Client. I have used the following config:
$config = array(
'username' => $username,
'password' => $password,
'hostspec' => 'imap.gmail.com',
'port' => '993',
'secure' => true,
"debug" => "imap.log",
"debug_literal" => true
);
I also tried ssl, sslv2, sslv3 and tls for the secure value. The Exception i got was Error when communicating with the mail server.
and the imap.log only showed me this
------------------------------
>> Thu, 28 Jan 2016 18:29:14 +0100
>> Connection to: imap://imap.gmail.com:993/
>> Server connection took 0.0156 seconds.
>> Slow Command: 10.018 seconds
>> ERROR: read/timeout error.
------------------------------
I also tried allowing "insecure apps" in my google account but the result was the same. Any clues? The connection works fine with our in-house IMAP server and the office365 IMAP server
Change
'secure' => true,
to
'secure' => 'tlsv1',
This will force TLSv1 connections.
I ran into this same problem myself. I posted to the Horde mailing list but was able to resolve the issue a day later on my own with the above change.