本文整理汇总了PHP中imap_alerts函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_alerts函数的具体用法?PHP imap_alerts怎么用?PHP imap_alerts使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_alerts函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkPassword
/**
* Check if the password is correct without logging in the user
*
* @param string $uid The username
* @param string $password The password
*
* @return true/false
*/
public function checkPassword($uid, $password)
{
if (!function_exists('imap_open')) {
OCP\Util::writeLog('user_external', 'ERROR: PHP imap extension is not installed', OCP\Util::ERROR);
return false;
}
// Check if we only want logins from ONE domain and strip the domain part from UID
if ($this->domain != '') {
$pieces = explode('@', $uid);
if (count($pieces) == 1) {
$username = $uid . "@" . $this->domain;
} elseif (count($pieces) == 2 and $pieces[1] == $this->domain) {
$username = $uid;
$uid = $pieces[0];
} else {
return false;
}
} else {
$username = $uid;
}
$mbox = @imap_open($this->mailbox, $username, $password, OP_HALFOPEN, 1);
imap_errors();
imap_alerts();
if ($mbox !== FALSE) {
imap_close($mbox);
$uid = mb_strtolower($uid);
$this->storeUser($uid);
return $uid;
} else {
return false;
}
}
示例2: checkPassword
/**
* @brief Check if the password is correct
* @param $uid The username
* @param $password The password
* @returns true/false
*
* Check if the password is correct without logging in the user
*/
public function checkPassword($uid, $password)
{
$mbox = @imap_open($this->mailbox, $uid, $password);
imap_errors();
imap_alerts();
if ($mbox) {
imap_close($mbox);
return $uid;
} else {
return false;
}
}
示例3: authenticate
/**
* Authenticate connection
*
* @param string $username Username
* @param string $password Password
*
* @return \Ddeboer\Imap\Connection
* @throws AuthenticationFailedException
*/
public function authenticate($username, $password)
{
$resource = @\imap_open($this->getServerString(), $username, $password, null, 1);
if (false === $resource) {
throw new AuthenticationFailedException($username);
}
$check = imap_check($resource);
$mailbox = $check->Mailbox;
$this->connection = substr($mailbox, 0, strpos($mailbox, '}') + 1);
// These are necessary to get rid of PHP throwing IMAP errors
imap_errors();
imap_alerts();
return new Connection($resource, $this->connection);
}
示例4: open
public function open($server, $username, $password, $mailbox, array $flags)
{
if (!empty($flags)) {
$server .= '/' . implode('/', $flags);
}
$mailbox = '{' . $server . '}' . $mailbox;
$this->resource = @imap_open($mailbox, $username, $password);
if (!$this->resource) {
$error = imap_last_error();
imap_errors();
imap_alerts();
throw new IMAPException($error);
}
return $this;
}
示例5: checkPassword
/**
* Check if the password is correct without logging in the user
*
* @param string $uid The username
* @param string $password The password
*
* @return true/false
*/
public function checkPassword($uid, $password)
{
if (!function_exists('imap_open')) {
OCP\Util::writeLog('user_external', 'ERROR: PHP imap extension is not installed', OCP\Util::ERROR);
return false;
}
$mbox = @imap_open($this->mailbox, $uid, $password, OP_HALFOPEN);
imap_errors();
imap_alerts();
if ($mbox !== FALSE) {
imap_close($mbox);
$this->storeUser($uid);
return $uid;
} else {
return false;
}
}
示例6: connect
function connect()
{
$this->conn = @imap_open('{' . $this->server . '/notls}', $this->user, $this->pass, null, 1);
// Supress alerts
imap_alerts();
$errors = imap_errors();
$searchword = 'AUTHENTICATIONFAILED';
$matches = array_filter($errors, function ($var) use($searchword) {
return preg_match("/\\b{$searchword}\\b/i", $var);
});
if (is_bool($this->conn) || !empty($matches)) {
$this->connected = false;
return false;
} else {
$this->connected = true;
return true;
}
}
示例7: authenticate
public function authenticate(array $credentials)
{
list($username, $password) = $credentials;
$loginData = $this->imapLoginModel->getBy(array("username" => $username));
$mbox = imap_open("{localhost:993/ssl/novalidate-cert}INBOX", $username, $password, OP_HALFOPEN | OP_SILENT);
imap_alerts();
imap_errors();
if (!$loginData) {
throw new \Nette\Security\AuthenticationException('Neznámé jméno uživatele.', self::IDENTITY_NOT_FOUND);
} elseif (!$mbox) {
throw new \Nette\Security\AuthenticationException('Nesprávné heslo.', self::INVALID_CREDENTIAL);
}
$identity = $this->buildIdentity($loginData->user_id);
$enabled = $identity->getData()["enabled"];
if (!$enabled) {
throw new \Nette\Security\AuthenticationException('Tento účet je zablokovaný.', self::INACTIVE);
}
$this->user->login($identity);
}
示例8: authenticate
/**
* Authenticate connection
*
* @param string $username Username
* @param string $password Password
*
* @return Connection
* @throws AuthenticationFailedException
*/
public function authenticate($username, $password)
{
// Wrap imap_open, which gives notices instead of exceptions
set_error_handler(function ($nr, $message) use($username) {
throw new AuthenticationFailedException($username, $message);
});
$resource = imap_open($this->getServerString(), $username, $password, null, 1, $this->parameters);
if (false === $resource) {
throw new AuthenticationFailedException($username);
}
restore_error_handler();
$check = imap_check($resource);
$mailbox = $check->Mailbox;
$this->connection = substr($mailbox, 0, strpos($mailbox, '}') + 1);
// These are necessary to get rid of PHP throwing IMAP errors
imap_errors();
imap_alerts();
return new Connection($resource, $this->connection);
}
示例9: __construct
/**
Initialize the mailbox connection.
The mailbox connection parameters are as follow:
* host: Host name of the server hosting the mailbox. Default: localhost.
* port: Port of the imap service. Default: 143.
* mailbox: Mailbox name. Default: INBOX.
* flags: Connection flags. Optionnal.
* user: User name.
* password: User password.
For a detailed list of available flags, please see the PHP documentation
for imap_open.
The connection to the mailbox is read-only until tested enough.
@param $aParams Mailbox connection parameters.
@see http://php.net/imap_open
*/
public function __construct($aParams)
{
function_exists('imap_open') or burn('ConfigurationException', _WT('The IMAP PHP extension is required by the weeFetchMail class.'));
empty($aParams['user']) and burn('InvalidParameterException', _WT('The user name was not provided in the connection parameters.'));
empty($aParams['password']) and burn('InvalidParameterException', _WT('The user password was not provided in the connection parameters.'));
// Fill in the default values
$aParams = $aParams + array('host' => 'localhost', 'port' => 143, 'mailbox' => 'INBOX');
$sConnection = '{' . $aParams['host'] . ':' . $aParams['port'];
if (!empty($aParams['flags'])) {
$sConnection .= $aParams['flags'];
}
$sConnection .= '}' . $aParams['mailbox'];
$this->rLink = @imap_open($sConnection, $aParams['user'], $aParams['password'], OP_READONLY, 1);
// We must clear the errors and alerts or they'll be thrown separately, possibly multiple times.
// Despite their names, those functions also clear the errors buffer.
imap_alerts();
$a = imap_errors();
// Then we only output the first error from the array we retrieved (usually good enough).
$this->rLink === false and burn('UnexpectedValueException', _WT("Couldn't open stream \"%s\" with the following error:\n%s", $sConnection, $a[0]));
}
示例10: open
/**
* Open the remote mailbox
*
* @param string|null $extension Extension of the serveur to open (/Inbox, ...)
*
* @return int|bool
*/
function open($extension = null)
{
$port = $this->source->port ? ":" . $this->source->port : "";
$protocole = $this->source->auth_ssl ? "https://" : "http://";
$url = $protocole . $this->source->host . $port;
if (!isset($this->_server)) {
CAppUI::stepAjax("CPop-error-notInitiated", UI_MSG_ERROR);
return false;
}
$password = $this->source->getPassword();
$server = $this->_server . $extension;
$this->_mailbox = @imap_open($server, $this->source->user, $password, 0, 0);
//avoid errors reporting
imap_errors();
imap_alerts();
if ($this->_mailbox === false) {
//CModelObject::warning("IMAP-warning-configuration-unreashable", $this->source->object_class, $this->source->object_id);
return false;
}
$this->_is_open = true;
return $this->_mailbox;
}
示例11: stat
/**
Get Status Messages
*/
function stat()
{
$r = null;
if ($this->_c) {
imap_check($this->_c);
}
$x = imap_alerts();
if (!empty($x)) {
$r .= "Alerts:\n " . implode('; ', $x) . "\n";
}
$x = imap_errors();
if (!empty($x)) {
$r .= "Errors:\n " . implode('; ', $x) . "\n";
}
return $r;
}
示例12: alerts
/**
* Wrapper function for {@link imap_alerts}. Implodes the array returned by imap_alerts,
* (if any) and returns the text.
*
* @param string $seperator Characters to seperate each alert message. '<br />\n' by default.
* @return string|FALSE
* @access public
* @see imap_alerts
* @see errors
*/
function alerts($seperator = "<br />\n")
{
$alerts = imap_alerts();
return is_array($alerts) && !empty($alerts) ? implode($seperator, $alerts) : FALSE;
}
示例13: connect
/**
* Connect To the Mail Box
*/
public function connect()
{
if (!function_exists('imap_open')) {
throw new \Exception('imap_open function must be enabled');
}
$this->setMailBox(@imap_open($this->getServer(), $this->getUsername(), $this->getPassword(), OP_SILENT));
$errors = imap_errors();
$alerts = imap_alerts();
if (!$this->getMailBox()) {
if (!$errors) {
$errors = array();
}
if (!$alerts) {
$alerts = array();
}
throw new \Exception("Error: " . implode('. ', array_merge($errors, $alerts)));
}
return $this->getMailBox();
}
示例14: handleBounce
handleBounce($type, $newsletterID, EZSOFTBOUNCE);
break;
case EZHARDBOUNCE:
handleBounce($type, $newsletterID, EZHARDBOUNCE);
break;
case EZNOBOUNCE:
default:
// TODO
break;
}
} else {
//do not delete
$delete = false;
}
$imapErrors = imap_errors();
$imapAlerts = imap_alerts();
if ($imapErrors) {
$cli->output("\nMAIL ID: {$mailID}");
print_r($imapErrors);
}
if ($imapAlerts) {
$cli->output("\nMAIL ID: {$mailID}");
print_r($imapAlerts);
}
if ($delete) {
imap_delete($mailbox, $i);
}
}
// Close imap connection
imap_close($mailbox, CL_EXPUNGE);
}
示例15: close
public function close($expunge = true)
{
imap_alerts();
imap_errors();
imap_close($this->imap, $expunge ? CL_EXPUNGE : 0);
}