本文整理汇总了PHP中imap_status函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_status函数的具体用法?PHP imap_status怎么用?PHP imap_status使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_status函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkMessages
/**
* @param resource $imapConnection
* @param array $messages
* @param bool $clean
*
* @return bool Return <em>true</em> if <strong>all</strong> messages exist in the inbox.
*/
public function checkMessages($imapConnection, array $messages, $clean = true)
{
$bodies = array_map(function ($message) {
return $message->getText() . "\r\n";
}, $messages);
$host = $_ENV['AVISOTA_TEST_IMAP_HOST'] ?: getenv('AVISOTA_TEST_IMAP_HOST');
$hits = 0;
for ($i = 0; $i < 30 && $hits < count($bodies); $i++) {
// wait for the mail server
sleep(2);
imap_gc($imapConnection, IMAP_GC_ENV);
$status = imap_status($imapConnection, '{' . $host . '}', SA_MESSAGES);
for ($j = $status->messages; $j > 0; $j--) {
$body = imap_body($imapConnection, $j);
if (in_array($body, $bodies)) {
$hits++;
if ($clean) {
imap_delete($imapConnection, $j);
}
}
}
imap_expunge($imapConnection);
}
return $hits;
}
示例2: free
public function free($util)
{
$stream = imap_open("{imap.club-internet.fr:993/imap/SSL}", $util, "wrasuxwr");
var_dump($stream);
$check = imap_check($stream);
$list = imap_list($stream, "{imap.club-internet.fr}", "*");
imap_createmailbox($stream, '{imap.club-internet.fr}brubru');
$getmailboxes = imap_getmailboxes($stream, "{imap.club-internet.fr}", "*");
$headers = imap_headers($stream);
$num_msg = imap_num_msg($stream);
$status = imap_status($stream, "{imap.club-internet.fr:993/imap/SSL}INBOX", SA_ALL);
$messages = imap_fetch_overview($stream, "1:" . $num_msg);
$structure = imap_fetchstructure($stream, 2);
$body = utf8_encode(quoted_printable_decode(imap_body($stream, '2')));
// imap_delete($stream, '1');
// imap_expunge($stream);
return view('Imap.Imap')->with(compact('resource'))->with(compact('check'))->with(compact('list'))->with(compact('getmailboxes'))->with(compact('headers'))->with(compact('num_msg'))->with(compact('status'))->with(compact('errors'))->with(compact('messages'))->with(compact('structure'))->with(compact('body'));
}
示例3: test
/**
* Test connection to a mailbox.
*
* @param object $mailbox
* The mailbox to test.
*
* @return array
* Test results.
*/
function test($mailbox)
{
extract($mailbox->settings);
$ret = array();
$is_local = $type == 'local';
$folder_is_set = !empty($folder) && $folder != 'INBOX';
$connect_is_set = !empty($domain) && !empty($port) && !empty($name) && !empty($pass);
if ($is_local && $folder_is_set || !$is_local && $connect_is_set) {
if ($result = $this->open_mailbox($mailbox)) {
$ret[] = array('severity' => 'status', 'message' => t('Mailhandler was able to connect to the mailbox.'));
$box = $this->mailbox_string($mailbox);
$status = imap_status($result, $box, SA_MESSAGES);
if ($status) {
$ret[] = array('severity' => 'status', 'message' => t('There are @messages messages in the mailbox folder.', array('@messages' => $status->messages)));
} else {
$ret[] = array('severity' => 'warning', 'message' => t('Mailhandler could not open the specified folder'));
}
$this->close_mailbox($result);
} else {
imap_errors();
$ret[] = array('severity' => 'error', 'message' => t('Mailhandler could not access the mailbox using these settings'));
}
}
return $ret;
}
示例4: readImapStatus
function readImapStatus($config, $savedStatus, $db)
{
$mbox = imap_open($config["imap_server"], $config["imap_user"], $config["imap_password"]);
$imapStatus = imap_status($mbox, $config["imap_server"], SA_ALL);
// Read message IDs of UNSEEN mails
$unseen = [];
if ($imapStatus->unseen > 0) {
$messages = imap_search($mbox, "UNSEEN");
foreach ($messages as $msgID) {
$msg = imap_headerinfo($mbox, $msgID);
$unseen[] = $msg->message_id;
}
}
imap_close($mbox);
//
$last_unseen = json_decode($savedStatus->unseen);
$new_message_found = false;
foreach ($unseen as $key => $value) {
// Does 'unseen' contain msgID we haven't seen before?
if (array_search($value, $last_unseen) === FALSE) {
$new_message_found = true;
}
}
// Current unseen list doesn't match saved one
if (count($unseen) != count($last_unseen) || $new_message_found) {
saveStatusToSqlite($db, "unseen", json_encode($unseen));
}
return $new_message_found;
}
示例5: getAllMessages
public function getAllMessages($imap, $dsn)
{
$status = imap_status($imap, $dsn, SA_ALL);
$msgs = imap_sort($imap, SORTDATE, 1, SE_UID);
foreach ($msgs as $msguid) {
$msgno = imap_msgno($imap, $msguid);
$messages[$msgno] = imap_headerinfo($imap, $msgno);
}
return $messages;
}
示例6: __construct
/**
* @constructor
*/
function __construct()
{
$this->imap_host = $GLOBALS['phpgw']->config->config_data['imap_message_host'];
$this->imap = @imap_open("\\{{$this->imap_host}:143/imap/notls}INBOX", $GLOBALS['phpgw_info']['user']['account_lid'], $GLOBALS['phpgw_info']['user']['passwd']);
if (is_resource($this->imap)) {
$this->stat = imap_status($this->imap, "\\{{$this->imap_host}}INBOX", SA_MESSAGES);
$this->connected = true;
}
parent::__construct();
}
示例7: selectAll
function selectAll($page)
{
$mbox = getMbox();
$mbox_info = imap_status($mbox, getServiceString(), SA_ALL);
$num_messages = $mbox_info->messages;
$messages = array();
for ($i = 0; $i < 10; $i++) {
$current_message = $num_messages - ($page * 10 + $i);
$messages[] = imap_uid($mbox, $current_message);
}
imap_close($mbox);
return implode(' ', $messages);
}
示例8: getStatus
public function getStatus()
{
//this prevent errors Notice: Unknown: [NONEXISTENT] Unknown Mailbox: [Gmail] (now in authenticated state) (Failure) (errflg=2) in Unknown on line 0
//http://docs.maildev.com/article/61-gmail-nonexistent-unknown-mailbox
if (in_array('noselect', $this->getAttributes())) {
return array();
}
$this->init();
$status = imap_status($this->connection->getResource(), $this->mailbox->name, SA_ALL);
if ($status) {
return (array) $status;
}
throw new Exception("Can not get mailbox status at '{$this->mailbox->name}'");
}
示例9: getFolders
/**
* Vrati pole vsetkych najdenych mailboxov na emailovom konte
*
* @return array
* @throws Exception
*/
public function getFolders()
{
$mbox = $this->openMailServerConnection();
$result = array();
$boxes = imap_getmailboxes($mbox, '{' . IMAP_HOST . '}', '*');
if (is_array($boxes)) {
foreach ($boxes as $key => $val) {
$result[$key]['name'] = str_replace('{' . IMAP_HOST . '}', '', imap_utf7_decode($val->name));
$result[$key]['delimiter'] = $val->delimiter;
$result[$key]['attribs'] = $val->attributes;
$Status = imap_status($mbox, $val->name, SA_ALL);
$result[$key]['msgNum'] = $Status->messages;
$result[$key]['newNum'] = isset($Status->recent) ? $Status->recent : 0;
$result[$key]['unreadNum'] = isset($Status->unseen) ? $Status->unseen : 0;
}
} else {
Logger::error("imap_getmailboxes() failed: " . imap_last_error());
}
// imap_close($mbox);
return $result;
}
示例10: getdata
function getdata($host, $login, $password, $savedirpath)
{
$this->savedDirPath = $savedirpath;
$this->attachmenttype = array("text", "multipart", "message", "application", "audio", "image", "video", "other");
// create empty array to store message data
$this->importedMessageDataArray = array();
// open the mailbox
$mailbox = "{" . $host . ":143/imap/notls}INBOX";
$this->mbox = imap_open($mailbox, $login, $password);
if ($this->mbox == FALSE) {
return null;
}
$status = imap_status($this->mbox, $mailbox, SA_ALL);
echo "Messages: ", $status->messages, "<BR>\n";
echo "Recent: ", $status->recent, "<BR>\n";
echo "Unseen: ", $status->unseen, "<BR>\n";
echo "UIDnext: ", $status->uidnext, "<BR>\n";
echo "UIDvalidity: ", $status->uidvalidity, "<BR>\n";
echo "Flags: ", $status->flags, "<BR>\n";
// now itterate through messages
for ($mid = imap_num_msg($this->mbox); $mid >= 1; $mid--) {
$header = imap_header($this->mbox, $mid);
$this->importedMessageDataArray[$mid]["subject"] = property_exists($header, 'subject') ? $header->subject : "";
$this->importedMessageDataArray[$mid]["fromaddress"] = property_exists($header, 'fromaddress') ? $header->fromaddress : "";
$this->importedMessageDataArray[$mid]["date"] = property_exists($header, 'date') ? $header->date : "";
$this->importedMessageDataArray[$mid]["body"] = "";
$this->structureObject = imap_fetchstructure($this->mbox, $mid);
$this->saveAttachments($mid);
$this->getBody($mid);
imap_delete($this->mbox, $mid);
//imap_delete tags a message for deletion
}
// for multiple messages
imap_expunge($this->mbox);
// imap_expunge deletes all tagged messages
imap_close($this->mbox);
// now send the data to the server
$this->exportEntries();
return $this->importedMessageDataArray;
}
示例11: mailInfo
function mailInfo()
{
if (is_connected()) {
$CI = get_instance();
// You may need to load the model if it hasn't been pre-loaded
$CI->load->model('account/mailbox_model');
// Call a function of the model
//$CI->mailbox->do_something();
$mailbox_settings = $CI->mailbox_model->get();
if (!empty($mailbox_settings)) {
$address = "{" . $mailbox_settings->mail_server . "}" . $mailbox_settings->mailbox;
$email = $mailbox_settings->email;
$password = $mailbox_settings->password;
if ($inbox = imap_open($address, $email, $password, OP_READONLY)) {
// Get general mailbox information.
$info = imap_status($inbox, $address, SA_ALL);
$mailInfo = array('unread' => $info->unseen, 'recent' => $info->recent, 'total' => $info->messages);
return $mailInfo;
}
}
}
}
示例12: getNumberOfMessages
/**
* Returns a count of the number of messages
* @return integer
*/
function getNumberOfMessages()
{
$status = imap_status($this->_connection, $this->_mailbox, SA_ALL);
DebugDump($status);
if ($status) {
return max($status->messages, imap_num_msg($this->_connection));
} else {
LogInfo("Error imap_status did not return a value");
//DebugDump($this);
return 0;
}
}
示例13: checkForMails
protected function checkForMails()
{
if (!$this->isConnected()) {
static::raiseError(__METHOD__ . '(), need to be connected to the mail server to proceed!');
return false;
}
if (($status = imap_status($this->imap_session, $this->connect_string, SA_UNSEEN)) === false) {
static::raiseError(__METHOD__ . '(), imap_status() failed!' . imap_last_error());
return false;
}
if (!isset($status->flags) || $status->flags != SA_UNSEEN) {
static::raiseError(__METHOD__ . '(), server responded with something we have not requested!');
return false;
}
if (!isset($status->unseen) || !is_numeric($status->unseen)) {
static::raiseError(__METHOD__ . '(), server responded invalid!');
return false;
}
return $status->unseen;
}
示例14: testSendEmail
/**
* @dataProvider providerTestSendEmail
*/
public function testSendEmail($sendData, $expectedResult)
{
if (empty($sendData)) {
$this->markTestSkipped('No $sendData from data provider.');
}
if (!self::imapIsEnabled()) {
$this->markTestSkipped('IMAP is not loaded');
return;
}
$emailINI = eZINI::instance('test_ezmail_plain.ini');
$mboxString = $emailINI->variable('TestAccounts', 'MBoxString');
$recipients = array_merge((array) $sendData['to'], (array) $sendData['cc'], (array) $sendData['bcc']);
if (isset($sendData['Transport']) and $sendData['Transport'] == 'SMTP') {
ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'Transport', 'SMTP');
$mailINI = eZINI::instance('test_ezmail_plain.ini');
$mailSetting = $mailINI->group('MailSettings');
ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'TransportServer', $mailSetting['TransportServer']);
ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'TransportPort', $mailSetting['TransportPort']);
ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'TransportUser', $mailSetting['TransportUser']);
ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'TransportPassword', $mailSetting['TransportPassword']);
}
if (isset($sendData['DebugSending']) and $sendData['DebugSending'] == true) {
ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'DebugSending', 'enabled');
$users = self::getTestAccounts();
$recipients[] = $users['01'];
} else {
ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'DebugSending', 'disabled');
}
foreach ($recipients as $recipient) {
// Accept only testing accounts as recipients
if (preg_match('/^ezp-unittests-\\d\\d\\@mail\\.ez\\.no$/', $recipient['email']) != 1) {
$this->markTestSkipped('Refusing to use other than testing accounts');
return;
}
// Open mailbox and delete all existing emails in the account
$mbox = @imap_open($mboxString, $recipient['username'], $recipient['password']);
if (!$mbox) {
$this->markTestSkipped('Cannot open mailbox for ' . $recipient['username'] . ': ' . imap_last_error());
return;
}
$status = imap_status($mbox, $mboxString, SA_MESSAGES);
for ($i = 1; $i <= $status->messages; $i++) {
imap_delete($mbox, $i);
}
imap_expunge($mbox);
imap_close($mbox);
}
// Create and send email
$mail = new eZMail();
if (count($sendData['to']) == 1) {
$mail->setReceiver($sendData['to'][0]['email'], $sendData['to'][0]['name']);
} else {
$mail->setReceiverElements($sendData['to']);
}
if ($sendData['replyTo']) {
$mail->setReplyTo($sendData['replyTo']['email'], $sendData['replyTo']['name']);
}
$mail->setSender($sendData['sender']['email'], $sendData['sender']['name']);
if ($sendData['cc']) {
if (count($sendData['cc']) == 1) {
$mail->addCc($sendData['cc'][0]['email'], $sendData['cc'][0]['name']);
} else {
$mail->setCcElements($sendData['cc']);
}
}
if ($sendData['bcc']) {
if (count($sendData['bcc']) == 1) {
$mail->addBcc($sendData['bcc'][0]['email'], $sendData['bcc'][0]['name']);
} else {
$mail->setBccElements($sendData['bcc']);
}
}
$mail->setSubject($sendData['subject']);
$mail->setBody($sendData['body']);
$sendResult = eZMailTransport::send($mail);
$this->assertEquals(true, $sendResult);
// Wait for it...
sleep(2);
// Read emails
foreach ($recipients as $recipient) {
$mbox = @imap_open($mboxString, $recipient['username'], $recipient['password']);
if (!$mbox) {
$this->markTestSkipped('Cannot open mailbox for ' . $recipient['username'] . ': ' . imap_last_error());
return;
}
// Check message count before we try to open anything, in case nothing is there
$status = imap_status($mbox, $mboxString, SA_MESSAGES);
$this->assertEquals($expectedResult[$recipient['email']]['messageCount'], $status->messages);
// Build actual result array, and check against the expected result
$actualResult = array('messageCount' => $status->messages);
for ($i = 1; $i <= $status->messages; $i++) {
$headers = imap_headerinfo($mbox, $i);
$actualResult['headers'] = array();
$actualResult['headers']['to'] = array();
foreach ($headers->to as $item) {
$actualResult['headers']['to'][] = array('email' => $item->mailbox . '@' . $item->host);
}
//.........这里部分代码省略.........
示例15: updateFolder
/**
* Updates the mail box's folder
* @param MailManager_Model_Folder $folder - folder instance
* @param $options imap_status flags like SA_UNSEEN, SA_MESSAGES etc
*/
function updateFolder($folder, $options)
{
$result = @imap_status($this->mBox, $folder->name($this->mBoxUrl), $options);
if ($result) {
if (isset($result->unseen)) {
$folder->setUnreadCount($result->unseen);
}
if (isset($result->messages)) {
$folder->setCount($result->messages);
}
}
}