Source for file IMAP.connection_wizard.php
Documentation is available at IMAP.connection_wizard.php
require_once 'Mail/IMAP.php';
* Attempts to find the appropriate URI for the user based on common
* configurations and port settings. This function is meant to serve
* as a utility helper to find the correct URI syntax to pass to
* @param string $server Remote mail server to connect to.
* @param string $user Remote mail server user name.
* @param string $pass Remote mail server password.
* @param string $protocol
* (optional) Mail server protocol, one of imap|pop3|nntp
* (optional) Mail server port.
* @todo add SSL/TLS URI testing
// Building/or/attempting to build the connection can take lots of time
ini_set('max_execution_time', 120 );
// imap_open throws lots of errors on failed attempts
$base_uri = urlencode($user). ':'. $pass. '@'. $server;
$protocol = array ('imap', 'pop3', 'nntp');
$port = array (143 , 110 , 119 );
for ($i = 0; $i < count($protocol); $i++ ) {
$uri = $protocol[$i]. '://'. $base_uri. ':'. $port[$i]. '/INBOX';
if (PEAR ::isError ($mail->connect ($uri))) {
if (!PEAR ::isError ($mail->connect ($uri. '#notls'))) {
case 'imap': $base_uri .= ($port == 0 )? ':143' : ':'. $port; break;
case 'pop3': $base_uri .= ($port == 0 )? ':110' : ':'. $port; break;
case 'nntp': $base_uri .= ($port == 0 )? ':119' : ':'. $port; break;
$uri = $protocol. '://'. $base_uri;
if (PEAR ::isError ($mail->connect ($uri))) {
if (!PEAR ::isError ($mail->connect ($uri. '#notls'))) {
Documentation generated on Mon, 11 Mar 2019 10:15:01 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|