Exemplo n.º 1
0
 /**
  * Create global IMAP object and connect to server
  *
  * @param boolean True if connection should be established
  * @todo Remove global $IMAP
  */
 public function imap_init($connect = false)
 {
     // already initialized
     if (is_object($this->imap)) {
         return;
     }
     $this->imap = new rcube_imap($this->db);
     $this->imap->debug_level = $this->config->get('debug_level');
     $this->imap->skip_deleted = $this->config->get('skip_deleted');
     // enable caching of imap data
     if ($this->config->get('enable_caching')) {
         $this->imap->set_caching(true);
     }
     // set pagesize from config
     $this->imap->set_pagesize($this->config->get('pagesize', 50));
     // Setting root and delimiter before establishing the connection
     // can save time detecting them using NAMESPACE and LIST
     $options = array('auth_method' => $this->config->get('imap_auth_type', 'check'), 'auth_cid' => $this->config->get('imap_auth_cid'), 'auth_pw' => $this->config->get('imap_auth_pw'), 'debug' => (bool) $this->config->get('imap_debug', 0), 'force_caps' => (bool) $this->config->get('imap_force_caps'), 'timeout' => (int) $this->config->get('imap_timeout', 0));
     $this->imap->set_options($options);
     // set global object for backward compatibility
     $GLOBALS['IMAP'] = $this->imap;
     $hook = $this->plugins->exec_hook('imap_init', array('fetch_headers' => $this->imap->fetch_add_headers));
     if ($hook['fetch_headers']) {
         $this->imap->fetch_add_headers = $hook['fetch_headers'];
     }
     // support this parameter for backward compatibility but log warning
     if ($connect) {
         $this->imap_connect();
         raise_error(array('code' => 800, 'type' => 'imap', 'file' => __FILE__, 'line' => __LINE__, 'message' => "rcube::imap_init(true) is deprecated, use rcube::imap_connect() instead"), true, false);
     }
 }
Exemplo n.º 2
0
    $a_host = parse_url($imap_host);
    if ($a_host['host']) {
        $imap_host = $a_host['host'];
        $imap_ssl = isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl', 'imaps', 'tls')) ? $a_host['scheme'] : null;
        if (isset($a_host['port'])) {
            $imap_port = $a_host['port'];
        } else {
            if ($imap_ssl && $imap_ssl != 'tls' && (!$imap_port || $imap_port == 143)) {
                $imap_port = 993;
            }
        }
    }
    $imap_host = idn_to_ascii($imap_host);
    $imap_user = idn_to_ascii($_POST['_user']);
    $imap = new rcube_imap(null);
    $imap->set_options(array('auth_type' => $RCI->getprop('imap_auth_type'), 'debug' => $RCI->getprop('imap_debug'), 'socket_options' => $RCI->getprop('imap_conn_options')));
    if ($imap->connect($imap_host, $imap_user, $_POST['_pass'], $imap_port, $imap_ssl)) {
        $RCI->pass('IMAP connect', 'SORT capability: ' . ($imap->get_capability('SORT') ? 'yes' : 'no'));
        $imap->close();
    } else {
        $RCI->fail('IMAP connect', $RCI->get_error());
    }
}
?>

<p><input type="submit" name="imaptest" value="Check login" /></p>

</form>

<hr />