I was receiving the following error while trying to add the /secure flag and verify that the /ssl flag was using TLS 1.2 instead of the very outdated SSL protocol:
PHP Request Shutdown: Can't do secure authentication with this server (errflg=2)
I ended up having to call my host to get help as there were literally only five pages in the search engines with the error. The mailbox configuration:
Before / incorrect / error:
<?php
$server_folder = '{mail.example.com:993/imap/ssl/secure}';
?>
After / correct / connected:
<?php
$server_folder = '{mail.example.com:993/ssl/imap/secure}';
?>
The /ssl and /imap flags were not in the correct order. Here is the thing, the flags listed above do NOT mention a strict chronological order of flags and are themselves no listed in the chronological order. So that right there is a bug report needed for the documentation though hopefully this comment will spare someone the aggravation for seemingly random errors. Good luck!