This method is used to access an IMAP/POP3/NNTP service.
public serviceMail ( string $url, string $serviceUrl, string $flags, &$err_code, &$err_msg, &$pt ) : object | ||
$url | string | a string giving the URL of the service, including the mailing box for IMAP URLs, as accepted by imap_open(). |
$serviceUrl | string | a string giving for CAS retrieve Proxy ticket |
$flags | string | options given to imap_open(). |
Résultat | object | an IMAP stream on success, false otherwise (in this later case, $err_code gives the reason why it failed and $err_msg contains an error message). |
/** * Verify that proxy-ticket Exceptions are caught and converted to error * codes in serviceMail(). * * @return void */ public function testServiceMailPtError() { $stream = $this->object->serviceMail('mailbox_name', 'imap://mail.example.edu/path/that/doesnt/exist', OP_READONLY, $err_code, $err_msg, $pt); $this->assertFalse($stream, "serviceMail() should have returned false on a PT error."); $this->assertEquals(PHPCAS_SERVICE_PT_FAILURE, $err_code); $this->assertStringStartsWith("PT retrieving failed", $err_msg); $this->assertFalse($pt, '$pt should be false.'); }
/** * This method is used to access an IMAP/POP3/NNTP service. * * @param string $url a string giving the URL of the service, * including the mailing box for IMAP URLs, as accepted by imap_open(). * @param string $service a string giving for CAS retrieve Proxy ticket * @param string $flags options given to imap_open(). * @param string &$err_code an error code Possible values are * PHPCAS_SERVICE_OK (on success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, * PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, PHPCAS_SERVICE_PT_FAILURE, * PHPCAS_SERVICE_NOT_AVAILABLE. * @param string &$err_msg an error message on failure * @param string &$pt the Proxy Ticket (PT) retrieved from the CAS * server to access the URL on success, false on error). * * @return object IMAP stream on success, false otherwise (in this later * case, $err_code gives the reason why it failed and $err_msg contains an * error message). */ public static function serviceMail($url, $service, $flags, &$err_code, &$err_msg, &$pt) { phpCAS::traceBegin(); phpCAS::_validateProxyExists(); try { $res = self::$_PHPCAS_CLIENT->serviceMail($url, $service, $flags, $err_code, $err_msg, $pt); } catch (Exception $e) { phpCAS::error(get_class($e) . ': ' . $e->getMessage()); } phpCAS::traceEnd($res); return $res; }