ezcMailImapTransport::__construct PHP Метод

__construct() публичный Метод

You can specify the $port if the IMAP server is not on the default port 993 (for SSL connections) or 143 (for plain connections). Use the $options parameter to specify an SSL connection. See {@link ezcMailImapTransportOptions} for options you can specify for IMAP. Example of creating an IMAP transport: replace with your IMAP server address $imap = new ezcMailImapTransport( 'imap.example.com' ); if you want to use SSL: $options = new ezcMailImapTransportOptions(); $options->ssl = true; $imap = new ezcMailImapTransport( 'imap.example.com', null, $options );
public __construct ( string $server, integer $port = null, ezcMailImapTransportOptions | array(string=>mixed) $options = [] )
$server string
$port integer
$options ezcMailImapTransportOptions | array(string=>mixed)
    public function __construct($server, $port = null, $options = array())
    {
        if ($options instanceof ezcMailImapTransportOptions) {
            $this->options = $options;
        } else {
            if (is_array($options)) {
                $this->options = new ezcMailImapTransportOptions($options);
            } else {
                throw new ezcBaseValueException("options", $options, "ezcMailImapTransportOptions|array");
            }
        }
        if ($port === null) {
            $port = $this->options->ssl === true ? 993 : 143;
        }
        $this->connection = new ezcMailTransportConnection($server, $port, $this->options);
        // get the server greeting
        $response = $this->connection->getLine();
        if (strpos($response, "* OK") === false) {
            throw new ezcMailTransportException("The connection to the IMAP server is ok, but a negative response from server was received. Try again later.");
        }
        if (strpos($response, self::SERVER_GIMAP) !== false) {
            $this->serverType = self::SERVER_GIMAP;
            // otherwise it is null
        }
        $this->state = self::STATE_NOT_AUTHENTICATED;
    }