使用IMAP和PHP阅读电子邮件 - 拒绝连接

I want to read a mail's inbox using PHP IMAP.

On phpinfo() i see both OpenSSL and IMAP enabled.

When trying to connect:

/* connect to inbox */
$hostname = "{imap-mail.outlook.com:993/imap/tls}INBOX";
$username = 'mail@...';
$password = 'password';

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Error: ' . imap_last_error());

It will always throw an error:

Can't connect to imap.glbdns2.microsoft.com,993: Connection refused (errflg=2)

On the outlook settings it says:

enter image description here

Why does this happen and how can I fix it?