• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imap_mail_move函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中imap_mail_move函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_mail_move函数的具体用法?PHP imap_mail_move怎么用?PHP imap_mail_move使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了imap_mail_move函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:optimumweb,项目名称:php-email-reader-parser,代码行数:13,代码来源:email_reader.php


示例2: moveMailToFolder

 /**
  * @param $mail_id
  * @param string $folder
  */
 public function moveMailToFolder($mail_id, $folder = 'INBOX/Junk')
 {
     $imapresult = imap_mail_move($this->getImapStream(), $mail_id, $folder, CP_UID);
     if (!$imapresult) {
         echo imap_last_error();
     }
 }
开发者ID:pnoreck,项目名称:mailscanner,代码行数:11,代码来源:Mailbox.php


示例3: fetch

 public function fetch(MailCriteria $criteria, $callback)
 {
     $mailbox = @imap_open('{' . $this->host . ':' . $this->port . '}INBOX', $this->username, $this->password);
     if (!$mailbox) {
         throw new ImapException("Cannot connect to imap server: {$this->host}:{$this->port}'");
     }
     $this->checkProcessedFolder($mailbox);
     $emails = $this->fetchEmails($mailbox, $criteria);
     if ($emails) {
         foreach ($emails as $emailIndex) {
             $overview = imap_fetch_overview($mailbox, $emailIndex, 0);
             $message = imap_body($mailbox, $emailIndex);
             $email = new Email($overview, $message);
             $processed = $callback($email);
             if ($processed) {
                 $res = imap_mail_move($mailbox, $emailIndex, $this->processedFolder);
                 if (!$res) {
                     throw new \Exception("Unexpected error: Cannot move email to ");
                     break;
                 }
             }
         }
     }
     @imap_close($mailbox);
 }
开发者ID:martinstrycek,项目名称:imap-mail-downloader,代码行数:25,代码来源:Downloader.php


示例4: 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();
 }
开发者ID:networksoft,项目名称:erp.multinivel,代码行数:8,代码来源:Email_reader.php


示例5: moveMail

 public function moveMail($mailId)
 {
     $imapresult = imap_mail_move($this->getImapStream(), $mailId, 'INBOX.Archive') && $this->expungeDeletedMails();
     if ($imapresult == false) {
         error_log(imap_last_error());
     }
     return $imapresult;
 }
开发者ID:escobar022,项目名称:wp_mailman,代码行数:8,代码来源:receivemail.class.php


示例6: mailcwp_delete_callback

function mailcwp_delete_callback()
{
    $result = array();
    $mailcwp_session = mailcwp_get_session();
    if (!isset($mailcwp_session) || empty($mailcwp_session)) {
        return;
    }
    $account = $mailcwp_session["account"];
    $use_ssl = $account["use_ssl"];
    //$from = $account["email"];
    $folder = $mailcwp_session["folder"];
    $use_tls = $account["use_tls"];
    $messages = $_POST["messages"];
    //write_log($messages);
    //write_log("DELETE MAIL " . print_r($account, true));
    $use_ssl_flag = $use_ssl === "true" ? "/ssl" : "";
    $use_tls_flag = $use_tls === "true" ? "/tls" : "";
    $mbox = mailcwp_imap_connect($account, 0, $folder);
    //write_log("SEND ACCOUNT " . print_r($account));
    $sent_folder = "";
    if (is_array($account)) {
        $trash_folder = $account["trash_folder"];
        if (empty($trash_folder)) {
            $trash_folder = mailcwp_find_folder($mbox, $account, "Trash");
            if (empty($trash_folder)) {
                $trash_folder = mailcwp_find_folder($mbox, $account, "Deleted");
            }
        }
        if (!empty($trash_folder) && $trash_folder != $folder) {
            //write_log("DELETE MOVE MESSAGES " . print_r($messages, true));
            imap_mail_move($mbox, $messages, $trash_folder);
            imap_expunge($mbox);
            $result["result"] = "OK";
            $result["message"] = "Moved to {$trash_folder}";
            $result["imap_errors"] = imap_errors();
        } else {
            imap_setflag_full($mbox, $messages, "\\Deleted");
            $result["result"] = "OK";
            if (!empty($trash_folder) && $folder == $trash_folder) {
                imap_expunge($mbox);
                $result["message"] = "Permanently Deleted";
            } else {
                $result["message"] = "Marked as Deleted";
            }
            $result["imap_errors"] = imap_errors();
        }
    } else {
        $result["result"] = "Failed";
        $result["message"] = "Account not found.";
    }
    //write_log("DELETE MESSAGES ($messages) " . print_r(imap_errors(), true));
    echo json_encode($result);
    die;
}
开发者ID:TouTrix,项目名称:mailcwp,代码行数:54,代码来源:mailcwp.php


示例7: getmails

 /**
  * @name: getmails
  * holt x Mails aus dem Postfach und parst diese nach Parts, oder sucht nur nach $subject
  *
  * @param $subject
  * @return Boolean
  */
 public function getmails($subject = 0)
 {
     imap_expunge($this->connection);
     $check = imap_mailboxmsginfo($this->connection);
     if (isset($subject) && !empty($subject)) {
         $mails = imap_search($this->connection, 'UNSEEN SUBJECT "' . substr(urldecode(subject), 0, 45) . '"', SE_UID);
     } else {
         $mails[0] = '*';
     }
     $mails = imap_fetch_overview($this->connection, "1:" . $mails[0], FT_UID);
     // Holt eine Uebersicht aller Emails
     $size = count($mails);
     // Anzahl der Nachrichten
     if ($size >= $this->config['counter']) {
         $size = $this->config['counter'];
     }
     for ($i = 0; $i < $size; $i++) {
         if ($i >= $this->config['counter']) {
             break;
         }
         $mails[$i]->subject = imap_utf8($mails[$i]->subject);
         $header = imap_fetchheader($this->connection, $mails[$i]->msgno);
         $struct = imap_fetchstructure($this->connection, $mails[$i]->msgno);
         $report = imap_fetchbody($this->connection, $mails[$i]->msgno, 2);
         $body = imap_fetchbody($this->connection, $mails[$i]->msgno, 1);
         $logs = imap_fetchbody($this->connection, $mails[$i]->msgno, 3);
         $this->mail[$i] = array('header' => $header, 'body' => $body, 'report' => $report, 'logs' => $logs, 'structur' => $struct, 'all' => $mails[$i]);
         $this->msgnr = $mails[$i]->msgno;
         if ($this->config['afterparse'] == 'delete') {
             imap_delete($this->connection, $mails[$i]->msgno . ':*');
         } elseif ($this->config['afterparse'] == 'move') {
             imap_mail_move($this->connection, $mails[$i]->msgno, $config['ordner'] . '.' . $this->config['movebox']);
         }
     }
     if ($this->config['afterparse'] == 'delete_all') {
         imap_delete($this->connection, "*");
     }
     imap_expunge($this->connection);
     if (!is_array($mails)) {
         $this->mail = 0;
     }
     return $this->mail;
 }
开发者ID:aalmenar,项目名称:validatexarf,代码行数:50,代码来源:validator.class.php


示例8: processMailbox


//.........这里部分代码省略.........
                     }
         */
         // fetch the messages one at a time
         if ($this->useFetchstructure) {
             $structure = imap_fetchstructure($this->mailboxLink, $x);
             if ($structure->type == 1 && $structure->ifsubtype && $structure->subtype == 'REPORT' && $structure->ifparameters && $this->isParameter($structure->parameters, 'REPORT-TYPE', 'delivery-status')) {
                 $processed = $this->processBounce($x, 'DSN', $totalCount);
             } else {
                 // not standard DSN msg
                 $this->output('Msg #' . $x . ' is not a standard DSN message', self::VERBOSE_REPORT);
                 if ($this->debugBodyRule) {
                     if ($structure->ifdescription) {
                         $this->output("  Content-Type : {$structure->description}", self::VERBOSE_DEBUG);
                     } else {
                         $this->output("  Content-Type : unsupported", self::VERBOSE_DEBUG);
                     }
                 }
                 $processed = $this->processBounce($x, 'BODY', $totalCount);
             }
         } else {
             $header = imap_fetchheader($this->mailboxLink, $x);
             // Could be multi-line, if the new line begins with SPACE or HTAB
             if (preg_match("/Content-Type:((?:[^\n]|\n[\t ])+)(?:\n[^\t ]|\$)/is", $header, $match)) {
                 if (preg_match("/multipart\\/report/is", $match[1]) && preg_match("/report-type=[\"']?delivery-status[\"']?/is", $match[1])) {
                     // standard DSN msg
                     $processed = $this->processBounce($x, 'DSN', $totalCount);
                 } else {
                     // not standard DSN msg
                     $this->output('Msg #' . $x . ' is not a standard DSN message', self::VERBOSE_REPORT);
                     if ($this->debugBodyRule) {
                         $this->output("  Content-Type : {$match[1]}", self::VERBOSE_DEBUG);
                     }
                     $processed = $this->processBounce($x, 'BODY', $totalCount);
                 }
             } else {
                 // didn't get content-type header
                 $this->output('Msg #' . $x . ' is not a well-formatted MIME mail, missing Content-Type', self::VERBOSE_REPORT);
                 if ($this->debugBodyRule) {
                     $this->output('  Headers: ' . $this->bmhNewLine . $header . $this->bmhNewLine, self::VERBOSE_DEBUG);
                 }
                 $processed = $this->processBounce($x, 'BODY', $totalCount);
             }
         }
         $deleteFlag[$x] = false;
         $moveFlag[$x] = false;
         if ($processed) {
             $processedCount++;
             if (!$this->disableDelete) {
                 // delete the bounce if not in disableDelete mode
                 if (!$this->testMode) {
                     @imap_delete($this->mailboxLink, $x);
                 }
                 $deleteFlag[$x] = true;
                 $deletedCount++;
             } elseif ($this->moveHard) {
                 // check if the move directory exists, if not create it
                 if (!$this->testMode) {
                     $this->mailboxExist($this->hardMailbox);
                 }
                 // move the message
                 if (!$this->testMode) {
                     @imap_mail_move($this->mailboxLink, $x, $this->hardMailbox);
                 }
                 $moveFlag[$x] = true;
                 $movedCount++;
             } elseif ($this->moveSoft) {
                 // check if the move directory exists, if not create it
                 if (!$this->testMode) {
                     $this->mailboxExist($this->softMailbox);
                 }
                 // move the message
                 if (!$this->testMode) {
                     @imap_mail_move($this->mailboxLink, $x, $this->softMailbox);
                 }
                 $moveFlag[$x] = true;
                 $movedCount++;
             }
         } else {
             // not processed
             $unprocessedCount++;
             if (!$this->disableDelete && $this->purgeUnprocessed) {
                 // delete this bounce if not in disableDelete mode, and the flag BOUNCE_PURGE_UNPROCESSED is set
                 if (!$this->testMode) {
                     @imap_delete($this->mailboxLink, $x);
                 }
                 $deleteFlag[$x] = true;
                 $deletedCount++;
             }
         }
         flush();
     }
     $this->output($this->bmhNewLine . 'Closing mailbox, and purging messages');
     imap_close($this->mailboxLink);
     $this->output('Read: ' . $fetchedCount . ' messages');
     $this->output($processedCount . ' action taken');
     $this->output($unprocessedCount . ' no action taken');
     $this->output($deletedCount . ' messages deleted');
     $this->output($movedCount . ' messages moved');
     return true;
 }
开发者ID:natxet,项目名称:PHPMailer-BMH,代码行数:101,代码来源:BounceMailHandler.php


示例9: removeEamil

 /**
  * 移动/移除 邮件
  * @param $mid
  */
 public function removeEamil($mid)
 {
     if (!$this->marubox) {
         return false;
     } else {
         imap_mail_move($this->marubox, $mid, 'INBOX');
     }
 }
开发者ID:lovecheng,项目名称:brs-demo2,代码行数:12,代码来源:Email.php


示例10: move

 /**
  * Move message to another mailbox
  *
  * @param integer $msgno Message number to move
  * @param string $mbox Mailbox to move message to
  * @return boolean
  */
 function move($msgno, $mbox)
 {
     // Only imap supports moving of mesages
     if ($server_type == "imap") {
         $list = imap_list($this->conn, $this->server, "*");
         if (!in_array($mbox, $list)) {
             if (!imap_createmailbox($this->conn, imap_utf7_encode($this->server . $mbox))) {
                 // $_ENV['api']['sys']->log("Creation of $mbox mailbox failed!","mailer");
             }
         }
         return imap_mail_move($this->conn, $msgno, $mbox);
     } else {
         return imap_delete($this->conn, $msgno);
     }
 }
开发者ID:laiello,项目名称:pivotx-sqlite,代码行数:22,代码来源:mail.class.php


示例11: move

 /**
  * Move message to another mailbox
  *
  * @param Mailbox $mailbox
  *
  * @throws MessageMoveException
  * @return Message
  */
 public function move(Mailbox $mailbox)
 {
     if (!imap_mail_move($this->stream, $this->messageNumber, $mailbox->getName(), \CP_UID)) {
         throw new MessageMoveException($this->messageNumber, $mailbox->getName());
     }
     return $this;
 }
开发者ID:shapecode,项目名称:imap,代码行数:15,代码来源:Message.php


示例12: deleteMails

 /**
  * Delete mail from that mail box
  *
  * @param $mid       String    mail Id
  * @param $folder    String   folder to move (delete if empty) (default '')
  *
  * @return Boolean
  **/
 function deleteMails($mid, $folder = '')
 {
     if (!empty($folder) && isset($this->fields[$folder]) && !empty($this->fields[$folder])) {
         $name = mb_convert_encoding($this->fields[$folder], "UTF7-IMAP", "UTF-8");
         if (imap_mail_move($this->marubox, $mid, $name)) {
             return true;
         }
         // raise an error and fallback to delete
         //TRANS: %1$s is the name of the folder, %2$s is the name of the receiver
         trigger_error(sprintf(__('Invalid configuration for %1$s folder in receiver %2$s'), $folder, $this->getName()));
     }
     return imap_delete($this->marubox, $mid);
 }
开发者ID:remicollet,项目名称:glpi,代码行数:21,代码来源:mailcollector.class.php


示例13: imap_fetchbody

            if ($overview[0]->from == "[email protected]" && $overview[0]->seen == 0) {
                // 			if ( $overview[0]->from == "[email protected]" ) {
                // 				$output.= "". $email_number ." - ";
                // 				$output.= "". $overview[0]->from .": ";
                // 				$output.= "". $overview[0]->subject.": ";
                // 				$output.= "". $overview[0]->seen ."\n";
                // 				$output.= "". $overview[0]->date ."\n";
                $message = imap_fetchbody($inbox, $email_number, 1);
                // 				echo $output;
                // 				echo $message;
                date_default_timezone_set("America/New_York");
                $date = date_create($overview[0]->date);
                $filename = date_format($date, 'dMY');
                //				$path = "$myhome/temp/Grades/";
                // 				$f = fopen("$myhome/file.txt", "w");
                $f = fopen($path . "" . $filename . "", "w");
                fwrite($f, "" . $message . "");
                fclose($f);
                // 				10Dec2013
                imap_mail_move($inbox, "{$email_number}", 'School');
                break;
            }
        }
    }
    /* close the connection */
    imap_close($inbox);
}
//else {
//	echo "$filename IS in $path\n";
//	exit(0);
//}
开发者ID:mpalermo73,项目名称:scripts-git,代码行数:31,代码来源:Grades_FetchLexGrades.php


示例14: MoveMessage

 /**
  * Called when the user moves an item on the PDA from one folder to another
  *
  * @param string              $folderid            id of the source folder
  * @param string              $id                  id of the message
  * @param string              $newfolderid         id of the destination folder
  * @param ContentParameters   $contentparameters
  *
  * @access public
  * @return boolean                      status of the operation
  * @throws StatusException              could throw specific SYNC_MOVEITEMSSTATUS_* exceptions
  */
 public function MoveMessage($folderid, $id, $newfolderid, $contentparameters)
 {
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->MoveMessage('%s','%s','%s')", $folderid, $id, $newfolderid));
     $folderImapid = $this->getImapIdFromFolderId($folderid);
     $newfolderImapid = $this->getImapIdFromFolderId($newfolderid);
     if ($folderImapid == $newfolderImapid) {
         throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, destination folder is source folder. Canceling the move.", $folderid, $id, $newfolderid), SYNC_MOVEITEMSSTATUS_SAMESOURCEANDDEST);
     }
     $this->imap_reopen_folder($folderImapid);
     if ($this->imap_inside_cutoffdate(Utils::GetCutOffDate($contentparameters->GetFilterType()), $id)) {
         // read message flags
         $overview = @imap_fetch_overview($this->mbox, $id, FT_UID);
         if (!is_array($overview)) {
             throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, unable to retrieve overview of source message: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID);
         } else {
             // get next UID for destination folder
             // when moving a message we have to announce through ActiveSync the new messageID in the
             // destination folder. This is a "guessing" mechanism as IMAP does not inform that value.
             // when lots of simultaneous operations happen in the destination folder this could fail.
             // in the worst case the moved message is displayed twice on the mobile.
             $destStatus = imap_status($this->mbox, $this->server . $newfolderImapid, SA_ALL);
             if (!$destStatus) {
                 throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, unable to open destination folder: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_INVALIDDESTID);
             }
             $newid = $destStatus->uidnext;
             // move message
             $s1 = imap_mail_move($this->mbox, $id, $newfolderImapid, CP_UID);
             if (!$s1) {
                 throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, copy to destination folder failed: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_CANNOTMOVE);
             }
             // delete message in from-folder
             $s2 = imap_expunge($this->mbox);
             // open new folder
             $stat = $this->imap_reopen_folder($newfolderImapid);
             if (!$stat) {
                 throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, opening the destination folder: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_CANNOTMOVE);
             }
             // remove all flags
             $s3 = @imap_clearflag_full($this->mbox, $newid, "\\Seen \\Answered \\Flagged \\Deleted \\Draft", FT_UID);
             $newflags = "";
             $move_to_trash = strcasecmp($newfolderImapid, $this->create_name_folder(IMAP_FOLDER_TRASH)) == 0;
             if ($overview[0]->seen || $move_to_trash && defined('IMAP_AUTOSEEN_ON_DELETE') && IMAP_AUTOSEEN_ON_DELETE == true) {
                 $newflags .= "\\Seen";
             }
             if ($overview[0]->flagged) {
                 $newflags .= " \\Flagged";
             }
             if ($overview[0]->answered) {
                 $newflags .= " \\Answered";
             }
             $s4 = @imap_setflag_full($this->mbox, $newid, $newflags, FT_UID);
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): result s-move: '%s' s-expunge: '%s' unset-Flags: '%s' set-Flags: '%s'", $folderid, $id, $newfolderid, Utils::PrintAsString($s1), Utils::PrintAsString($s2), Utils::PrintAsString($s3), Utils::PrintAsString($s4)));
             // return the new id "as string"
             return $newid . "";
         }
     } else {
         throw new StatusException(sprintf("BackendIMAP->MoveMessage(): Message is outside the sync range"), SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID);
     }
 }
开发者ID:peterbeck,项目名称:Z-Push-contrib,代码行数:71,代码来源:imap.php


示例15: imapMailMove

 /**
  * verschiebt die Nachricht mit der gegebenen uid in die gegebene Mailbox *auf dem selben Server*
  * @param integer $uid
  * @param string $dest_mbox
  * @return boolean
  */
 public function imapMailMove($uid, $dest_mbox)
 {
     if ($this->imap === null) {
         throw new IMAPException(__METHOD__ . ' not connected');
     }
     $this->imapPing(true);
     /*
      * dont't add the server part,
      * only the mailbox name works fine
      *
      * $dest_mbox = $this->server.$dest_mbox;
      */
     return imap_mail_move($this->imap, $uid, $dest_mbox, CP_UID);
 }
开发者ID:NEOatNHNG,项目名称:cacert-testmgr,代码行数:20,代码来源:imapConnection.php


示例16: imap_fetchstructure

for ($X = 1; $X <= $msgCount; $X++) {
    // loop over the messages
    $info = imap_fetchstructure($mbox, $X);
    //$X is the message number
    //echo "<br> data from email -> ";print"<pre>";print_r($info);print"</pre>";
    $numparts = count($info->parts);
    // how may parts the message has
    $Y = 2;
    //setting up a counter..not elegant, but it will work
    foreach ($info->parts as $part) {
        //loop over the parts of the message part 1 is message body ( doesn't contain 'disposition') part 2 is the attachment
        if (isset($part->disposition)) {
            if ($part->disposition == 'attachment') {
                $name = $part->dparameters[1]->value;
                //echo 'the attachment -> ' . $name. '<br>' ;
                //write the file to the folder
                $file = imap_fetchbody($mbox, $X, $Y);
                $dec = base64_decode($file);
                file_put_contents($path . $name, $dec);
                //move the emails to the completed mailbox
                //echo 'the path -> ' . $path.$name;
                imap_mail_move($mbox, $X, 'Inbox/Completed');
                $Y = $Y + 1;
                //incase there are more than 1 attachments
            }
        }
    }
}
//leave the moving of emails to the cron version
imap_expunge($mbox);
imap_close($mbox);
开发者ID:jimlongo56,项目名称:bhouse,代码行数:31,代码来源:daily_prices_email.old.php


示例17: MoveMessage

 /**
  * Called when the user moves an item on the PDA from one folder to another
  *
  * @param string              $folderid            id of the source folder
  * @param string              $id                  id of the message
  * @param string              $newfolderid         id of the destination folder
  * @param ContentParameters   $contentparameters
  *
  * @access public
  * @return boolean                      status of the operation
  * @throws StatusException              could throw specific SYNC_MOVEITEMSSTATUS_* exceptions
  */
 public function MoveMessage($folderid, $id, $newfolderid, $contentparameters)
 {
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->MoveMessage('%s','%s','%s')", $folderid, $id, $newfolderid));
     $folderImapid = $this->getImapIdFromFolderId($folderid);
     // SDB: When iOS is configured to "Archive Message" (instead of Delete Message), it will send a "MoveItems"
     // command to the Exchange server and attempt to move it to a folder called "0/Archive". Instead, we trap that
     // and send it to "[Gmail]/All Mail" folder instead. Note, that when on iOS device and you trigger a move from
     // folder A to B, it will correctly move that email, including to all folders with "[Gmail]...".
     if ($newfolderid == "0/Archive") {
         $newfolderImapid = "[Gmail]/All Mail";
     } else {
         $newfolderImapid = $this->getImapIdFromFolderId($newfolderid);
     }
     if ($folderImapid == $newfolderImapid) {
         throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, destination folder is source folder. Canceling the move.", $folderid, $id, $newfolderid), SYNC_MOVEITEMSSTATUS_SAMESOURCEANDDEST);
     }
     $this->imap_reopen_folder($folderImapid);
     if ($this->imap_inside_cutoffdate(Utils::GetCutOffDate($contentparameters->GetFilterType()), $id)) {
         // read message flags
         $overview = @imap_fetch_overview($this->mbox, $id, FT_UID);
         if (!is_array($overview)) {
             throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, unable to retrieve overview of source message: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID);
         } else {
             // get next UID for destination folder
             // when moving a message we have to announce through ActiveSync the new messageID in the
             // destination folder. This is a "guessing" mechanism as IMAP does not inform that value.
             // when lots of simultaneous operations happen in the destination folder this could fail.
             // in the worst case the moved message is displayed twice on the mobile.
             $destStatus = imap_status($this->mbox, $this->server . $newfolderImapid, SA_ALL);
             if (!$destStatus) {
                 throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, unable to open destination folder: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_INVALIDDESTID);
             }
             $newid = $destStatus->uidnext;
             // move message
             $s1 = imap_mail_move($this->mbox, $id, $newfolderImapid, CP_UID);
             if (!$s1) {
                 throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, copy to destination folder failed: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_CANNOTMOVE);
             }
             // delete message in from-folder
             $s2 = imap_expunge($this->mbox);
             // open new folder
             $stat = $this->imap_reopen_folder($newfolderImapid);
             if (!$s1) {
                 throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, opening the destination folder: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_CANNOTMOVE);
             }
             // remove all flags
             $s3 = @imap_clearflag_full($this->mbox, $newid, "\\Seen \\Answered \\Flagged \\Deleted \\Draft", FT_UID);
             $newflags = "";
             if ($overview[0]->seen) {
                 $newflags .= "\\Seen";
             }
             if ($overview[0]->flagged) {
                 $newflags .= " \\Flagged";
             }
             if ($overview[0]->answered) {
                 $newflags .= " \\Answered";
             }
             $s4 = @imap_setflag_full($this->mbox, $newid, $newflags, FT_UID);
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): result s-move: '%s' s-expunge: '%s' unset-Flags: '%s' set-Flags: '%s'", $folderid, $id, $newfolderid, Utils::PrintAsString($s1), Utils::PrintAsString($s2), Utils::PrintAsString($s3), Utils::PrintAsString($s4)));
             // return the new id "as string"
             return $newid . "";
         }
     } else {
         throw new StatusException(sprintf("BackendIMAP->MoveMessage(): Message is outside the sync range"), SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID);
     }
 }
开发者ID:alanturing1,项目名称:Z-Push-contrib,代码行数:78,代码来源:imap.php


示例18: postbyemail_imap

/**
 * postbyemail_imap()
 *
 * Grabs unread messages from an imap account and saves them as .eml files
 * Passes any new messages found to the postby email function for processing
 * Called by a scheduled task or cronjob
 */
function postbyemail_imap()
{
    global $modSettings;
    // No imap, why bother?
    if (!function_exists('imap_open')) {
        return false;
    }
    // Values used for the connection
    $hostname = !empty($modSettings['maillist_imap_host']) ? $modSettings['maillist_imap_host'] : '';
    $username = !empty($modSettings['maillist_imap_uid']) ? $modSettings['maillist_imap_uid'] : '';
    $password = !empty($modSettings['maillist_imap_pass']) ? $modSettings['maillist_imap_pass'] : '';
    $mailbox = !empty($modSettings['maillist_imap_mailbox']) ? $modSettings['maillist_imap_mailbox'] : 'INBOX';
    $type = !empty($modSettings['maillist_imap_connection']) ? $modSettings['maillist_imap_connection'] : '';
    // I suppose that without these informations we can't do anything.
    if (empty($hostname) || empty($username) || empty($password)) {
        return;
    }
    // Based on the type selected get/set the additional connection details
    $connection = port_type($type);
    $hostname .= strpos($hostname, ':') === false ? ':' . $connection['port'] : '';
    $server = '{' . $hostname . '/' . $connection['protocol'] . $connection['flags'] . '}';
    $mailbox = $server . imap_utf7_encode($mailbox);
    // Connect to the mailbox using the supplied credentials and protocol
    $inbox = @imap_open($mailbox, $username, $password);
    if ($inbox === false) {
        return false;
    }
    // If using gmail, we may need the trash bin name as well
    $trash_bin = '';
    if (!empty($modSettings['maillist_imap_delete']) && strpos($hostname, '.gmail.') !== false) {
        $trash_bin = get_trash_folder($inbox, $server);
    }
    // Grab all unseen emails, return by message ID
    $emails = imap_search($inbox, 'UNSEEN', SE_UID);
    // You've got mail,
    if ($emails) {
        // Initialize Emailpost controller
        require_once CONTROLLERDIR . '/Emailpost.controller.php';
        $controller = new Emailpost_Controller();
        // Make sure we work from the oldest to the newest message
        sort($emails);
        // For every email...
        foreach ($emails as $email_uid) {
            // Get the headers and prefetch the body as well to avoid a second request
            $headers = imap_fetchheader($inbox, $email_uid, FT_PREFETCHTEXT | FT_UID);
            $message = imap_body($inbox, $email_uid, FT_UID);
            // Create the save-as email
            if (!empty($headers) && !empty($message)) {
                $email = $headers . "\n" . $message;
                $controller->action_pbe_post($email);
                // Mark it for deletion?
                if (!empty($modSettings['maillist_imap_delete'])) {
                    // Gmail labels make this more complicated
                    if (strpos($hostname, '.gmail.') !== false) {
                        imap_mail_move($inbox, $email_uid, $trash_bin, CP_UID);
                    }
                    imap_delete($inbox, $email_uid, FT_UID);
                    imap_expunge($inbox);
                }
            }
        }
        // Close the connection
        imap_close($inbox);
        return true;
    } else {
        return false;
    }
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:75,代码来源:email_imap_cron.php


示例19: MoveMessage

 function MoveMessage($folderid, $id, $newfolderid)
 {
     debugLog("IMAP-MoveMessage: (sfid: '{$folderid}'  id: '{$id}'  dfid: '{$newfolderid}' )");
     $this->imap_reopenFolder($folderid);
     // read message flags
     $overview = @imap_fetch_overview($this->_mbox, $id, FT_UID);
     if (!$overview) {
         debugLog("IMAP-MoveMessage: Failed to retrieve overview");
         return false;
     } else {
         // move message
         $s1 = imap_mail_move($this->_mbox, $id, str_replace(".", $this->_serverdelimiter, $newfolderid), FT_UID);
         // delete message in from-folder
         $s2 = imap_expunge($this->_mbox);
         // open new folder
         $this->imap_reopenFolder($newfolderid);
         // remove all flags
         $s3 = @imap_clearflag_full($this->_mbox, $id, "\\Seen \\Answered \\Flagged \\Deleted \\Draft", FT_UID);
         $newflags = "";
         if ($overview[0]->seen) {
             $newflags .= "\\Seen";
         }
         if ($overview[0]->flagged) {
             $newflags .= " \\Flagged";
         }
         if ($overview[0]->answered) {
             $newflags .= " \\Answered";
         }
         $s4 = @imap_setflag_full($this->_mbox, $id, $newflags, FT_UID);
         debugLog("MoveMessage: (" . $folderid . "->" . $newfolderid . ") s-move: {$s1}   s-expunge: {$s2}    unset-Flags: {$s3}    set-Flags: {$s4}");
         return $s1 && $s2 && $s3 && $s4;
     }
 }
开发者ID:BackupTheBerlios,项目名称:z-push-svn,代码行数:33,代码来源:imap.php


示例20: moveMail

 /**
  * Moves mails listed in mailId into new mailbox
  * @return bool
  */
 public function moveMail($mailId, $mailBox)
 {
     return imap_mail_move($this->getImapStream(), $mailId, $mailBox, CP_UID) && $this->expungeDeletedMails();
 }
开发者ID:ladybirdweb,项目名称:momo-email-listener,代码行数:8,代码来源:Mailbox.php



注:本文中的imap_mail_move函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imap_mailboxmsginfo函数代码示例发布时间:2022-05-15
下一篇:
PHP imap_mail_copy函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap