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;
}