本文整理汇总了PHP中imap_expunge函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_expunge函数的具体用法?PHP imap_expunge怎么用?PHP imap_expunge使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_expunge函数的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: move
function move($uid, $folder)
{
$tries = 0;
while ($tries++ < 3) {
if (imap_mail_move($this->stream, $uid, $folder, CP_UID)) {
imap_expunge($this->stream);
return true;
} else {
sleep(1);
}
}
return false;
}
示例3: __destruct
/**
* Disconnects the current IMAP connection.
*/
public function __destruct()
{
if ($this->ressource) {
imap_expunge($this->ressource);
imap_close($this->ressource);
}
}
示例4: Close
/**
* Close the connection to the mail server
*
* @param bool $empty_trash (default true) whether to empty the trash upon exit
*
*/
function Close($empty_trash = true)
{
if ($this->do_delete && $empty_trash) {
imap_expunge($this->mbox);
}
imap_close($this->mbox);
}
示例5: deleteMessages
function deleteMessages($messages)
{
$mbox = getMbox();
$messages = uidToSecuence($mbox, $messages);
imap_delete($mbox, $messages);
imap_expunge($mbox);
imap_close($mbox);
}
示例6: move
function move($msg_index, $folder = 'INBOX.Processed')
{
// move on server
imap_mail_move($this->conn, $msg_index, $folder);
imap_expunge($this->conn);
// re-read the inbox
$this->inbox();
}
示例7: delete
public function delete($msg_index)
{
// move on server
imap_delete($this->conn, $msg_index);
imap_expunge($this->conn);
// re-read the inbox
$this->inbox();
}
示例8: _disconnect
private static function _disconnect()
{
if (!self::$_conn) {
return;
}
imap_expunge(self::$_conn);
imap_close(self::$_conn);
self::$_conn = null;
}
示例9: disconnect
private function disconnect()
{
if (!$this->handle) {
return;
}
//deletes all mails marked for deletion
imap_expunge($this->handle);
imap_close($this->handle);
}
示例10: deleteMessage
public function deleteMessage($id)
{
$status = imap_setflag_full($this->mailbox, $id, '\\Deleted');
imap_expunge($this->mailbox);
header("Location: /");
/* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
return $status;
}
示例11: delete
function delete($stream, $msg_num, $flags = 0)
{
// do we force use of msg UID's
if ($this->force_msg_uids == True && !($flags & FT_UID)) {
$flags |= FT_UID;
}
$retval = imap_delete($stream, $msg_num, $flags);
// some lame pop3 servers need this extra call to expunge, but RFC says not necessary
imap_expunge($stream);
return $retval;
}
示例12: process
/**
* Process emails by invoking of callback processing function.
* @param $callback function Function which should be executed for every email. This function should take an Email object as a parameter and return boolean as a result of processing.
* @param $senders list of comma-separated emails/names. This parameter is optional and is used to filter incoming mail by senders. false by default.
* @param $should_delete boolean Optional parameter. If this parameter is true and callback function returned true, email will be deleted.
*/
public function process($callback, $senders = false, $should_delete = false)
{
if ($senders) {
$senders = split(",", $senders);
}
if (is_array($senders) && !empty($senders)) {
foreach ($senders as $sender) {
if ($sender == '') {
continue;
}
$this->_process('FROM "' . $sender . '"', $callback, $should_delete);
}
} else {
$this->_process('ALL', $callback, $should_delete);
}
imap_expunge($this->connection);
}
示例13: 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;
}
示例14: while
while ($a = $ie->db->fetchByAssoc($r)) {
$ieX = new InboundEmail();
$ieX->retrieve($a['id']);
$ieX->connectMailserver();
//$newMsgs = $ieX->getNewMessageIds();
$newMsgs = array();
if ($ieX->isPop3Protocol()) {
$newMsgs = $ieX->getPop3NewMessagesToDownload();
} else {
$newMsgs = $ieX->getNewMessageIds();
}
if (is_array($newMsgs)) {
foreach ($newMsgs as $k => $msgNo) {
$uid = $msgNo;
if ($ieX->isPop3Protocol()) {
$uid = $ieX->getUIDLForMessage($msgNo);
} else {
$uid = imap_uid($ieX->conn, $msgNo);
}
// else
$ieX->importOneEmail($msgNo, $uid);
}
}
imap_expunge($ieX->conn);
imap_close($ieX->conn);
}
header('Location: index.php?module=Emails&action=ListViewGroup');
} else {
// fail gracefully
header('Location: index.php?module=Emails&action=index');
}
示例15: chamado_mail
//.........这里部分代码省略.........
}
$h .= $c < count($headers->cc) - 1 ? '; ' : '';
}
$h .= "<br />\n";
}
$headers->subject = strip_tags($headers->subject);
#if($controle_id_empresa == 1 && $controle_id_usuario == 1){
if (substr_count($headers->subject, 'iso-8859-1') > 0) {
$subject = imap_mime_header_decode($headers->subject);
$headers->subject = $subject[0]->text;
}
#}
$h .= "<b>Enviada em: </b>" . $headers->date . "<br />\n";
$h .= "<b>Assunto: </b>" . $headers->subject . "<br /><br />\n\n";
$msg = imap_qprint(imap_body($mbox, $i));
$msg = strip_tags($msg);
if (substr_count($msg, 'Content-ID') > 0) {
$msg = explode("Content-ID", $msg);
$msg = explode("\n", $msg[0]);
} else {
$msg = explode("\n", $msg);
}
$mensagem = '';
for ($k = 0; $k < count($msg); $k++) {
$msg[$k] = str_replace(' ', ' ', $msg[$k]);
$msg[$k] = trim($msg[$k]);
if (strlen(trim($msg[$k])) > 0) {
$cont = $this->LimparLinha($msg[$k]);
if ($cont == 0 && strlen(trim($msg[$k])) > 0) {
if (substr_count($msg[$k], 'De: ') > 0) {
if (substr_count($msg[$k], '@cartoriopostal.com.br') > 0 || substr_count($msg[$k], '@softfox.com.br') > 0 || substr_count($msg[$k], '@sistecart.com.br') > 0 || substr_count($msg[$k], '@seupetcomsobrenome.com.br') > 0 || substr_count($msg[$k], '@franchiseemporium.com.br') > 0) {
$k = count($msg);
} else {
$mensagem .= $msg[$k] . "<br /><br />\n\n";
}
} else {
$mensagem .= $msg[$k] . "<br /><br />\n\n";
}
}
}
}
# **************************************************************
if (strlen($mensagem) > 0) {
#if($controle_id_empresa == 1 && $controle_id_usuario == 1){
$mensagem = $h . $mensagem;
$stt = substr_count(strtolower($headers->subject), '| aberto') == 0 || ubstr_count(strtolower($headers->subject), '|aberto') == 0 ? 1 : 0;
$headers->subject = str_replace('| aberto', '', $headers->subject);
$headers->subject = str_replace('|aberto', '', $headers->subject);
$headers->subject = str_replace('RES: ', '', $headers->subject);
$headers->subject = trim($headers->subject);
# **************************************************************
$this->sql = "SELECT c.* FROM vsites_chamado AS c WHERE \n\t\t\t\t\t\t\t\t(c.pergunta LIKE '%" . $headers->subject . "%') AND c.id_empresa = ? AND c.id_usuario = ?";
$this->values = array($empresa, $usuario);
$dt = $this->fetch();
if (count($dt) == 0) {
$this->fields = array('id_pedido', 'ordem', 'id_empresa', 'id_usuario', 'status', 'pergunta', 'resposta', 'data_cadastro', 'data_atualizacao', 'forma_atend');
$this->values = array('id_pedido' => 0, 'ordem' => 0, 'id_empresa' => $empresa, 'id_usuario' => $usuario, 'status' => $stt, 'pergunta' => $headers->subject, 'resposta' => $mensagem, 'data_cadastro' => $data, 'data_atualizacao' => $data, 'forma_atend' => 2);
if ($controle_id_empresa == 1 && $controle_id_usuario == 1) {
$dt = $this->insert();
} else {
$this->insert();
#comentar se precisar
}
} else {
if ($dt[0]->status == 0) {
$sql = 'UPDATE ' . $this->table . ' SET status=?, data_atualizacao=?, pergunta=?, resposta=? ';
$sql .= 'WHERE id_chamado = ?';
$this->sql = $sql;
$this->values = array($stt, date('Y-m-d H:i:s'), $headers->subject, $mensagem . $dt[0]->resposta, $dt[0]->id_chamado);
if ($controle_id_empresa == 1 && $controle_id_usuario == 1) {
$dt = $this->exec();
} else {
$this->exec();
#comentar se precisar
}
}
}
#}
}
#echo $mensagem."\n\n\n";
}
if ($controle_id_empresa == 1 && $controle_id_usuario == 1) {
#$headers = imap_header($mbox, $i);
#$teste = imap_headerinfo($mbox, $i);
#print_r($teste); echo "\n\n";
print_r(imap_errors());
exit;
imap_delete($mbox, $i);
print_r(imap_errors());
echo $headers->message_id;
}
}
if ($controle_id_empresa == 1 && $controle_id_usuario == 1) {
imap_expunge($mbox);
}
}
if ($controle_id_empresa == 1 && $controle_id_usuario == 1) {
imap_close($mbox);
}
}