From b0d22fb76c3e8dea9662c9b482e7db4cb8b393af Mon Sep 17 00:00:00 2001 From: David Rainsford Date: Thu, 3 Apr 2014 10:59:19 +1100 Subject: [PATCH] Allow the passing of connection parameters to imap_open() Since version 5.3.2 of PHP, imap_open() has an optional 6th parameter which allows you to set certain connection parameters. Currently the only key is: - DISABLE_AUTHENTICATOR - Disable authentication properties see https://bugs.php.net/bug.php?id=33500 Example of use: $server = new Server('imap.example.com', 993); $server->setParam('DISABLE_AUTHENTICATOR', 'GSSAPI'); This gets rid of the following errors:
Notice: Unknown: Unknown GSSAPI failure: An invalid name was supplied (errflg=1) in Unknown on line 0

Notice: Unknown: GSSAPI mechanism status: Hostname cannot be canonicalized (errflg=1) in Unknown on line 0
--- src/Fetch/Server.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Fetch/Server.php b/src/Fetch/Server.php index 34a7bf6..89c19da 100644 --- a/src/Fetch/Server.php +++ b/src/Fetch/Server.php @@ -93,6 +93,13 @@ class Server */ protected $options = 0; + /** + * This is the set of connection parameters + * + * @var array + */ + protected $params = array(); + /** * This is the resource connection to the server. It is required by a number of imap based functions to specify how * to connect. @@ -224,6 +231,16 @@ class Server $this->options = $bitmask; } + /** + * This function is used to set connection parameters + * + * @param string $key + * @param string $value + */ + public function setParam($key, $value) { + $this->params[$key] = $value; + } + /** * This function gets the current saved imap resource and returns it. * @@ -287,7 +304,7 @@ class Server if (!imap_reopen($this->imapStream, $this->getServerString(), $this->options, 1)) throw new \RuntimeException(imap_last_error()); } else { - $imapStream = imap_open($this->getServerString(), $this->username, $this->password, $this->options, 1); + $imapStream = imap_open($this->getServerString(), $this->username, $this->password, $this->options, 1, $this->params); if ($imapStream === false) throw new \RuntimeException(imap_last_error());