Source for file IMAP.php
Documentation is available at IMAP.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Jeroen Houben <jeroen@terena.nl> |
// +----------------------------------------------------------------------+
// $Id: IMAP.php,v 1.9 2004/03/28 23:41:09 yavo Exp $
require_once "Auth/Container.php";
* Storage driver for fetching login data from an IMAP server
* This class is based on LDAP containers, but it very simple.
* By default it connects to localhost:143
* The constructor will first check if the host:port combination is
* actually reachable. This behaviour can be disabled.
* It then tries to create an IMAP stream (without opening a mailbox)
* If you wish to pass extended options to the connections, you may
* do so by specifying protocol options.
* To use this storage containers, you have to use the
* 'host' => 'mail.example.com',
* $myAuth = new Auth('IMAP', $params);
* By default we connect without any protocol options set. However, some
* servers require you to connect with the notls or norsh options set.
* To do this you need to add the following value to the params array:
* 'baseDSN' => '/imap/notls/norsh'
* To connect to an SSL IMAP server:
* 'baseDSN' => '/imap/ssl'
* To connect to an SSL IMAP server with a self-signed certificate:
* 'baseDSN' => '/imap/ssl/novalidate-cert'
* Further options may be available and can be found on the php site at
* http://www.php.net/manual/function.imap-open.php
* @author Jeroen Houben <jeroen@terena.nl>, Cipriano Groenendal <cipri@campai.nl>
* @version $Revision: 1.9 $
* Constructor of the container class
* @param $params, associative hash with host,port,basedn and userattr key
* @param $params, associative array with host, port, baseDSN, checkServer key.
* @return object Returns an error object if something went wrong
return PEAR ::raiseError ("Cannot use IMAP authentication, IMAP extension not loaded!",
// set parameters (if any)
$this->_parseOptions ($params);
if ($this->options['checkServer']) {
$this->_checkServer ($this->options['timeout']);
* Set some default options
$this->options['host'] = 'localhost';
$this->options['checkServer'] = true;
* Check if the given server and port are reachable
function _checkServer () {
$errno, $errstr, $this->options['timeout']);
$message = "Error connecting to IMAP server "
return PEAR ::raiseError ($message, 41 , PEAR_ERROR_DIE );
* Parse options passed to the container class
function _parseOptions ($array)
foreach ($array as $key => $value) {
* Try to open a IMAP stream using $username / $password
$conn = @imap_open ($dsn, $username, $password, OP_HALFOPEN );
Documentation generated on Mon, 11 Mar 2019 13:52:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|