I used up all possible combinations of hostname but I always either get a certificate error or just IMAP connection broken.
Certificate failure for im
The certificate is plain invalid. You should either connect to imap.mailboxhost.com:993/imap/ssl
or contact the administrator of the mail server and ask for a valid certificate.
Note that while you can use the connection string imap.froiden.com:993/imap/ssl/novalidate-cert
to skip certificate validation, you should not do so as that flag will allow any Man In The Middle attacker to read and write your email.
In case you're using gmail, make sure you turn on "Allow access for less secure apps" in the account settings page of your google account for you to be able to access your gmail account using imap_open()
I can confirm this is working well:
$mb = imap_open("{phoenix.srv.spletnasoba.si:993/imap/ssl/novalidate-cert}","username", "password" );
$emails = array();
$messageCount = imap_num_msg($mb);
for( $MID = 1; $MID <= $messageCount; $MID++ )
{
$EmailHeaders = imap_headerinfo( $mb, $MID );
foreach($EmailHeaders as $key => $value) {
if (validateEmail($value)) {
$emails[$value] = $key;
echo $value."\n";
}
}
}
function validateEmail($email) {
return filter_var($email, FILTER_VALIDATE_EMAIL);
}