I have been trying to get the host information (hostname, port, prefix...) like PHP IMAP extension does, but I can't figure out. example string:
$host = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX'
The closer I came up was PHPMailer does (code taken from source code):
$hostinfo = array();
if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) {
die(' Not a valid host entry');
}
// $hostinfo[2]: optional ssl or tls prefix
// $hostinfo[3]: the hostname
// $hostinfo[4]: optional port number
// The host string prefix can temporarily override the current setting for SMTPSecure
// If it's not specified, the default value is used
But I can't get there.
Any help will be much appreciated.