本文整理汇总了PHP中imap_errors函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_errors函数的具体用法?PHP imap_errors怎么用?PHP imap_errors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_errors函数的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: __destruct
function __destruct()
{
// You will have iMap errors, even if there are no
// mails on the server. This suppresses that error.
imap_errors();
imap_close($this->connection);
}
示例3: addAccount
function addAccount($_hookValues)
{
#_debug_array($_hookValues);
$username = $_hookValues['account_lid'];
$userPassword = $_hookValues['new_passwd'];
#_debug_array($this->profileData);
$imapAdminUsername = $this->profileData['imapAdminUsername'];
$imapAdminPW = $this->profileData['imapAdminPW'];
$folderNames = array("user.{$username}", "user.{$username}.Trash", "user.{$username}.Sent");
// create the mailbox
if ($mbox = @imap_open($this->getMailboxString(), $imapAdminUsername, $imapAdminPW)) {
// create the users folders
foreach ($folderNames as $mailBoxName) {
if (imap_createmailbox($mbox, imap_utf7_encode("{" . $this->profileData['imapServer'] . "}{$mailBoxName}"))) {
if (!imap_setacl($mbox, $mailBoxName, $username, "lrswipcd")) {
# log error message
}
}
}
imap_close($mbox);
} else {
_debug_array(imap_errors());
return false;
}
// subscribe to the folders
if ($mbox = @imap_open($this->getMailboxString(), $username, $userPassword)) {
imap_subscribe($mbox, $this->getMailboxString('INBOX'));
imap_subscribe($mbox, $this->getMailboxString('INBOX.Sent'));
imap_subscribe($mbox, $this->getMailboxString('INBOX.Trash'));
imap_close($mbox);
} else {
# log error message
}
}
示例4: download_and_process_email_replies
/**
* Primary method for downloading and processing email replies
*/
public function download_and_process_email_replies($connection_details)
{
imap_timeout(IMAP_OPENTIMEOUT, apply_filters('supportflow_imap_open_timeout', 5));
$ssl = $connection_details['imap_ssl'] ? '/ssl' : '';
$ssl = apply_filters('supportflow_imap_ssl', $ssl, $connection_details['imap_host']);
$mailbox = "{{$connection_details['imap_host']}:{$connection_details['imap_port']}{$ssl}}";
$inbox = "{$mailbox}{$connection_details['inbox']}";
$archive_box = "{$mailbox}{$connection_details['archive']}";
$imap_connection = imap_open($mailbox, $connection_details['username'], $connection_details['password']);
$redacted_connection_details = $connection_details;
$redacted_connection_details['password'] = '[redacted]';
// redact the password to avoid unnecessarily exposing it in logs
$imap_errors = imap_errors();
SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, $imap_connection ? __('Successfully opened IMAP connection.', 'supportflow') : __('Failed to open IMAP connection.', 'supportflow'), compact('redacted_connection_details', 'mailbox', 'imap_errors'));
if (!$imap_connection) {
return new WP_Error('connection-error', __('Error connecting to mailbox', 'supportflow'));
}
// Check to see if the archive mailbox exists, and create it if it doesn't
$mailboxes = imap_getmailboxes($imap_connection, $mailbox, '*');
if (!wp_filter_object_list($mailboxes, array('name' => $archive_box))) {
imap_createmailbox($imap_connection, $archive_box);
}
// Make sure here are new emails to process
$email_count = imap_num_msg($imap_connection);
if ($email_count < 1) {
SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, __('No new messages to process.', 'supportflow'), compact('mailboxes'));
return false;
}
$emails = imap_search($imap_connection, 'ALL', SE_UID);
$email_count = min($email_count, apply_filters('supportflow_max_email_process_count', 20));
$emails = array_slice($emails, 0, $email_count);
$processed = 0;
// Process each new email and put it in the archive mailbox when done.
foreach ($emails as $uid) {
$email = new stdClass();
$email->uid = $uid;
$email->msgno = imap_msgno($imap_connection, $email->uid);
$email->headers = imap_headerinfo($imap_connection, $email->msgno);
$email->structure = imap_fetchstructure($imap_connection, $email->msgno);
$email->body = $this->get_body_from_connection($imap_connection, $email->msgno);
if (0 === strcasecmp($connection_details['username'], $email->headers->from[0]->mailbox . '@' . $email->headers->from[0]->host)) {
$connection_details['password'] = '[redacted]';
// redact the password to avoid unnecessarily exposing it in logs
SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, __('Skipping message because it was sent from a SupportFlow account.', 'supportflow'), compact('email'));
continue;
}
// @todo Confirm this a message we want to process
$result = $this->process_email($imap_connection, $email, $email->msgno, $connection_details['username'], $connection_details['account_id']);
// If it was successful, move the email to the archive
if ($result) {
imap_mail_move($imap_connection, $email->uid, $connection_details['archive'], CP_UID);
$processed++;
}
}
imap_close($imap_connection, CL_EXPUNGE);
$status_message = sprintf(__('Processed %d emails', 'supportflow'), $processed);
SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, $status_message);
return $status_message;
}
示例5: Close
public function Close()
{
//$this->IMAP2->setOptions('close', CL_EXPUNGE);
$this->IMAP2->Expunge();
$this->IMAP2->Close();
imap_errors();
// Clear error stack.
}
示例6: grabEventsFromEmailAction
public function grabEventsFromEmailAction()
{
//echo phpinfo();
$m = new manage_model_event();
$m->emailGrab();
core_debug::dump($m);
core_debug::dump(imap_errors());
die('at ctrl');
}
示例7: __construct
public function __construct($mailbox, $username, $password, $code = null, $previous = null) {
$this->mailbox = $mailbox;
$this->username = $username;
$this->password = $password;
$this->imapErrors = \imap_errors();
$message = 'Error connecting to: '.$mailbox.' with user: '.$username.' ['. \imap_last_error().']';
parent::__construct($message, $code, $previous);
}
示例8: __construct
/**
* Constructor - Establishes Connection to Email Host
*/
function __construct($emailHost, $emailPort, $emailOptions, $emailLogin, $emailPassword, $catchAllBase = NULL)
{
$hostString = "{{$emailHost}:{$emailPort}/{$emailOptions}}";
$this->mbox = imap_open($hostString, $emailLogin, $emailPassword, OP_SILENT) or die("can't connect: " . print_r(imap_errors()));
// Remove all mail that may have been marked for deletion
// via another process, E.g script that died
imap_expunge($this->mbox);
$this->connected = TRUE;
$this->catchAllBase = $catchAllBase;
}
示例9: open
function open($mailbox = '')
{
if ($this->stream) {
$this->close();
}
$this->target = "{" . $this->host . ":" . $this->port . "/" . $this->mode . ($this->security != "none" ? "/" . $this->security . "/novalidate-cert" : "") . "/readonly}";
$this->stream = imap_open($this->target . $mailbox, $this->username, $this->password);
if (!$this->stream) {
throw new \Exception(implode(", ", imap_errors()));
}
}
示例10: 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;
}
}
示例11: initialize
/**
* Set the server, login, pass, service_flags, and mailbox
*
*/
public function initialize($init_array)
{
// connect to the specified account
// these array items need to be the
// same names as the config items OR
// the db table fields that store the account info
$this->host = $init_array['host'];
$this->port = $init_array['port'];
// get the port and server combined
$this->server = $this->host . ':' . $this->port;
$this->login = $init_array['login'];
$this->pass = $init_array['pass'];
$this->service_flags = $init_array['service_flags'];
// default to INBOX mailbox since POP3 doesn't require it
// and IMAP always has an INBOX
$this->mailbox = isset($init_array['mailbox']) ? $init_array['mailbox'] : 'INBOX';
// grab the resource returned by imap_open()
// concatenate the IMAP connect spec string
// expects server, flags, and mailbox to be set already
$this->server_spec_string = $this->_generate_server_spec_string();
// suppress warning with @ so we can handle it internally
// which is the way that imap_errors() works
$this->resource = @imap_open($this->server_spec_string, $this->login, $this->pass);
// check for errors in the connection
// calling imap_errors() clears all errors in the stack
$err = imap_errors();
// clear the message count in case this is a re-initialization
$this->message_count = NULL;
if ($this->resource) {
$this->log_state('Connected to: ' . $this->server_spec_string);
// when connection is good but the mailbox is empty,
// the php imap c-libs report POP server empty mailbox as
// "Mailbox is empty" (as a PHP error in the imap_errors() stack)
// in case we are using IMAP, we also check get_message_count()
if ($err[0] === 'Mailbox is empty' or $this->get_message_count() === 0) {
// we now know there are zero messages
$this->message_waiting = FALSE;
$this->log_state('Mailbox is empty.');
} else {
// there is at least one message
$this->message_waiting = TRUE;
$this->log_state('At least one message available.');
}
$this->connected = TRUE;
} else {
// determine the specific reason for rejection/no connection
$this->_handle_rejection($err);
$this->log_state('Not connected. No email resource at: ' . $this->server_spec_string);
$this->connected = FALSE;
}
}
示例12: Logoff
function Logoff()
{
if ($this->_mbox) {
// list all errors
$errors = imap_errors();
if (is_array($errors)) {
foreach ($errors as $e) {
debugLog("IMAP-errors: {$e}");
}
}
@imap_close($this->_mbox);
debugLog("IMAP connection closed");
}
}
示例13: 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);
}
示例14: get_imap_connection
function get_imap_connection()
{
$mbox = imap_open("{xxx.xxx.xxx.xxx:xxx/pop3/novalidate-cert}INBOX", "xml", "password") or die("can't connect: " . imap_last_error());
if ($mbox) {
// call this to avoid the mailbox is empty error message
if (imap_num_msg($mbox) == 0) {
$errors = imap_errors();
if ($errors) {
die("can't connect: " . imap_last_error());
}
}
}
return $mbox;
}
示例15: 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;
}