当前位置: 首页>>代码示例>>PHP>>正文


PHP imap_delete函数代码示例

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


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

示例1: fetch

 public function fetch($delete = false)
 {
     $oImap = imap_open('{' . $this->mail_server . ':993/imap/ssl/notls/novalidate-cert}', $this->username, $this->password);
     $oMailboxStatus = imap_check($oImap);
     $aMessages = imap_fetch_overview($oImap, "1:{$oMailboxStatus->Nmsgs}");
     $validMessages = array();
     foreach ($aMessages as $oMessage) {
         print "Trying message '" . $oMessage->subject . "'";
         $fileContent = $fileType = '';
         $geocoder = factory::create('geocoder');
         $postCode = $geocoder->extract_postcode($oMessage->subject);
         $fromName = null;
         $fromEmail = null;
         if (strpos($oMessage->from, '<')) {
             $split = split('<', $oMessage->from);
             //name - make sure name not an email address
             $fromName = trim($split[0]);
             if (valid_email($fromName)) {
                 $fromName = null;
             }
             //email
             $fromEmail = trim(str_replace('>', '', $split[1]));
         } else {
             $fromEmail = $oMessage->from;
         }
         $images = array();
         $messageStructure = imap_fetchstructure($oImap, $oMessage->msgno);
         if (isset($messageStructure->parts)) {
             $partNumber = 0;
             foreach ($messageStructure->parts as $oPart) {
                 $partNumber++;
                 if ($oPart->subtype == 'PLAIN' && !$postCode) {
                     $messageContent = imap_fetchbody($oImap, $oMessage->msgno, $partNumber);
                     if ($oPart->encoding == 4) {
                         $messageContent = quoted_printable_decode($messageContent);
                     }
                     $postCode = geocoder::extract_postcode($messageContent);
                 } elseif ($oPart->encoding == 3 && in_array($oPart->subtype, array('JPEG', 'PNG'))) {
                     $oImage = null;
                     $encodedBody = imap_fetchbody($oImap, $oMessage->msgno, $partNumber);
                     $fileContent = base64_decode($encodedBody);
                     $oImage = imagecreatefromstring($fileContent);
                     if (imagesx($oImage) > $this->min_import_size && imagesy($oImage) > $this->min_import_size) {
                         array_push($images, $oImage);
                     }
                     $fileType = strtolower($oPart->subtype);
                 }
             }
         }
         //add to the messages array
         array_push($validMessages, array('postcode' => $postCode, 'images' => $images, 'file_type' => $fileType, 'from_address' => $fromAddress, 'from_email' => $fromEmail, 'from_name' => $fromName));
         if ($delete) {
             imap_delete($oImap, $oMessage->msgno);
         }
     }
     imap_close($oImap, CL_EXPUNGE);
     $this->messages = $validMessages;
 }
开发者ID:schlos,项目名称:electionleaflets,代码行数:58,代码来源:mail_image.php

示例2: bounceprocessing


//.........这里部分代码省略.........
                 }
             } else {
                 switch ($hostencryption) {
                     case "OFF":
                         $hostname = $hostname . ":110";
                         break;
                     case "SSL":
                         $hostname = $hostname . ":995";
                         break;
                     case "TLS":
                         $hostname = $hostname . ":995";
                         break;
                 }
             }
         } else {
             $hostname = $hostname . ":" . $port;
         }
         $flags = "";
         switch ($accounttype) {
             case "IMAP":
                 $flags .= "/imap";
                 break;
             case "POP":
                 $flags .= "/pop3";
                 break;
         }
         switch ($hostencryption) {
             case "OFF":
                 $flags .= "/notls";
                 // Really Off
                 break;
             case "SSL":
                 $flags .= "/ssl/novalidate-cert";
                 break;
             case "TLS":
                 $flags .= "/tls/novalidate-cert";
                 break;
         }
         if ($mbox = @imap_open('{' . $hostname . $flags . '}INBOX', $username, $pass)) {
             imap_errors();
             $count = imap_num_msg($mbox);
             if ($count > 0) {
                 $lasthinfo = imap_headerinfo($mbox, $count);
                 $datelcu = strtotime($lasthinfo->date);
                 $datelastbounce = $datelcu;
                 $lastbounce = $thissurvey['bouncetime'];
                 while ($datelcu > $lastbounce) {
                     @($header = explode("\r\n", imap_body($mbox, $count, FT_PEEK)));
                     // Don't mark messages as read
                     foreach ($header as $item) {
                         if (preg_match('/^X-surveyid/', $item)) {
                             $iSurveyIdBounce = explode(": ", $item);
                         }
                         if (preg_match('/^X-tokenid/', $item)) {
                             $tokenBounce = explode(": ", $item);
                             if ($iSurveyId == $iSurveyIdBounce[1]) {
                                 $aData = array('emailstatus' => 'bounced');
                                 $condn = array('token' => $tokenBounce[1]);
                                 $record = Token::model($iSurveyId)->findByAttributes($condn);
                                 if ($record->emailstatus != 'bounced') {
                                     $record->emailstatus = 'bounced';
                                     $record->save();
                                     $bouncetotal++;
                                 }
                                 $readbounce = imap_body($mbox, $count);
                                 // Put read
                                 if (isset($thissurvey['bounceremove']) && $thissurvey['bounceremove']) {
                                     $deletebounce = imap_delete($mbox, $count);
                                     // Put delete
                                 }
                             }
                         }
                     }
                     $count--;
                     @($lasthinfo = imap_headerinfo($mbox, $count));
                     @($datelc = $lasthinfo->date);
                     $datelcu = strtotime($datelc);
                     $checktotal++;
                 }
             }
             @imap_close($mbox);
             $condn = array('sid' => $iSurveyId);
             $survey = Survey::model()->findByAttributes($condn);
             $survey->bouncetime = $datelastbounce;
             $survey->save();
             if ($bouncetotal > 0) {
                 printf($clang->gT("%s messages were scanned out of which %s were marked as bounce by the system."), $checktotal, $bouncetotal);
             } else {
                 printf($clang->gT("%s messages were scanned, none were marked as bounce by the system."), $checktotal);
             }
         } else {
             $clang->eT("Please check your settings");
         }
     } else {
         $clang->eT("Bounce processing is deactivated either application-wide or for this survey in particular.");
         return;
     }
     exit;
     // if bounceprocessing : javascript : no more todo
 }
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:101,代码来源:tokens.php

示例3: 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;
 }
开发者ID:avisota,项目名称:core,代码行数:32,代码来源:ImapMailboxChecker.php

示例4: getMail

 /**
  * Gets the mail from the inbox
  * Reads all the messages there, and adds posts based on them. Then it deletes the entire mailbox.
  */
 function getMail()
 {
     $config = Config::current();
     if (time() - 60 * $config->emailblog_minutes >= $config->emailblog_mail_checked) {
         $hostname = '{' . $config->emailblog_server . '}INBOX';
         # this isn't working well on localhost
         $username = $config->emailblog_address;
         $password = $config->emailblog_pass;
         $subjpass = $config->emailblog_subjpass;
         $inbox = imap_open($hostname, $username, $password) or exit("Cannot connect to Gmail: " . imap_last_error());
         $emails = imap_search($inbox, 'SUBJECT "' . $subjpass . '"');
         if ($emails) {
             rsort($emails);
             foreach ($emails as $email_number) {
                 $message = imap_body($inbox, $email_number);
                 $overview = imap_headerinfo($inbox, $email_number);
                 imap_delete($inbox, $email_number);
                 $title = htmlspecialchars($overview->Subject);
                 $title = preg_replace($subjpass, "", $title);
                 $clean = strtolower($title);
                 $body = htmlspecialchars($message);
                 # The subject of the email is used as the post title
                 # the content of the email is used as the body
                 # not sure about compatibility with images or audio feathers
                 Post::add(array("title" => $title, "body" => $message), $clean, Post::check_url($clean), "text");
             }
         }
         # close the connection
         imap_close($inbox, CL_EXPUNGE);
         $config->set("emailblog_mail_checked", time());
     }
 }
开发者ID:betsyzhang,项目名称:chyrp,代码行数:36,代码来源:emailblog.php

示例5: emailListener

function emailListener()
{
    $connection = establishConnection();
    $dbConn = establishDBConnection();
    $messagestatus = "UNSEEN";
    $emails = imap_search($connection, $messagestatus);
    if ($emails) {
        rsort($emails);
        foreach ($emails as $email_number) {
            // echo "in email loop";
            $header = imap_headerinfo($connection, $email_number);
            $message = imap_fetchbody($connection, $email_number, 1.1);
            if ($message == "") {
                $message = imap_fetchbody($connection, $email_number, 1);
            }
            $emailaddress = substr($header->senderaddress, stripos($header->senderaddress, "<") + 1, stripos($header->senderaddress, ">") - (stripos($header->senderaddress, ">") + 1));
            if (!detectOOOmessage($header->subject, $message, $emailaddress)) {
                detectBIOmessage($header->subject, $emailaddress);
            }
            imap_delete($connection, 1);
            //this might bug out but should delete the top message that was just parsed
        }
    }
    $dbConn->query("DELETE FROM away_mentor WHERE tiStamp <= DATE_ADD(NOW(), INTERVAL -1 DAY) limit 1");
    //delete mentors that have been away for more than 24 hours from the away list
}
开发者ID:acuba001,项目名称:Collaborative-Platform,代码行数:26,代码来源:AutoBackendOutOfTimeShow.php

示例6: delete

 public function delete($token)
 {
     if (!$this->box) {
         return false;
     }
     imap_delete($this->box, $token);
 }
开发者ID:tricardo,项目名称:CartorioPostal_old,代码行数:7,代码来源:ReceiveImapDAO.php

示例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();
 }
开发者ID:evo42,项目名称:willzahlen.at,代码行数:8,代码来源:mail-process.php

示例8: 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;
     }
     return imap_delete($stream, $msg_num, $flags);
 }
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:8,代码来源:class.mail_dcom_imap.inc.php

示例9: deleteMessages

function deleteMessages($messages)
{
    $mbox = getMbox();
    $messages = uidToSecuence($mbox, $messages);
    imap_delete($mbox, $messages);
    imap_expunge($mbox);
    imap_close($mbox);
}
开发者ID:palako,项目名称:mobilewebmail,代码行数:8,代码来源:performaction.php

示例10: deletemsgs

function deletemsgs($mbox, $first_msg_no, $last_msg_no)
{
    if (imap_delete($mbox, "{$first_msg_no}:{$last_msg_no}")) {
        return true;
    } else {
        print imap_last_error() . "\n";
        return false;
    }
}
开发者ID:Jensen-Technologies,项目名称:imap-importing,代码行数:9,代码来源:archive.php

示例11: deleteMail

 /**
  * Deletes the letter from inbox
  * 
  * @param integet/string $mid The number of letter in mailbox 
  * 
  * @return boolean
  */
 public function deleteMail($mid, $uid = 0)
 {
     // TODO: Move this method to the Migur library.
     // It is not relayed to com_newsletter explicitly
     if (!empty($this->_mailbox_link)) {
         return @imap_delete($this->_mailbox_link, $mid, $uid);
     }
     return false;
 }
开发者ID:Rikisha,项目名称:proj,代码行数:16,代码来源:lib.php

示例12: 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;
 }
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:11,代码来源:class.mail_dcom_pop3.inc.php

示例13: _getMailList

 private function _getMailList()
 {
     $mbox = imap_open(sprintf("{%s:%d/imap/ssl}INBOX", $this->_server, $this->_port), $this->_email, $this->_password);
     $mailList = imap_search($mbox, 'ALL');
     $bodyList = array();
     if (is_array($mailList)) {
         foreach ($mailList as $num) {
             $body = imap_fetchbody($mbox, $num, "1");
             array_push($bodyList, $body);
             imap_delete($mbox, $num);
         }
     }
     return $bodyList;
 }
开发者ID:havvg,项目名称:sfCloudControlPlugin,代码行数:14,代码来源:CCImap.php

示例14: purge_message

 function purge_message($mailbox, $message)
 {
     if (isset($message['imap_uid'])) {
         if ($result = $this->open_mailbox($mailbox)) {
             if ($mailbox->settings['delete_after_read']) {
                 imap_delete($result, $message['imap_uid'], FT_UID);
             } elseif (!isset($mailbox->settings['flag_after_read']) || $mailbox->settings['flag_after_read']) {
                 imap_setflag_full($result, (string) $message['imap_uid'], '\\Seen', FT_UID);
             }
             $this->close_mailbox($result);
         } else {
             drupal_set_message(t('Unable to connect to mailbox.'));
             watchdog('mailhandler', 'Unable to connect to %mail', array('%mail' => $mailbox->mail), WATCHDOG_ERROR);
         }
     }
 }
开发者ID:tierce,项目名称:ppbe,代码行数:16,代码来源:MailhandlerPhpImapRetrieve.class.php

示例15: emailListener

function emailListener()
{
    //$output = "<script>console.log( 'just got in' );</script>";
    //echo $output;
    $connection = establishConnection();
    $dbConn = establishDBConnection();
    //$output = "<script>console.log( 'set up connection' );</script>";
    //$dbConn->query("INSERT INTO away_mentor (userID, tiStamp) VALUES (99897, NOW())");//test the db connection
    //echo $output;//develop thread/loop
    $messagestatus = "UNSEEN";
    $countTo24 = 0;
    while (true) {
        echo "in check loop";
        $emails = imap_search($connection, $messagestatus);
        if ($emails) {
            rsort($emails);
            foreach ($emails as $email_number) {
                echo "in email loop";
                $header = imap_headerinfo($connection, $email_number);
                $message = imap_fetchbody($connection, $email_number, 1.1);
                if ($message == "") {
                    $message = imap_fetchbody($connection, $email_number, 1);
                }
                $emailaddress = substr($header->senderaddress, stripos($header->senderaddress, "<") + 1, stripos($header->senderaddress, ">") - (stripos($header->senderaddress, ">") + 1));
                if (!detectOOOmessage($header->subject, $message, $emailaddress)) {
                    detectB00message($header->subject, $emailaddress);
                }
                imap_delete($connection, 1);
                //this might bug out but should delete the top message that was just parsed
            }
        }
        sleep(600);
        //do check every 10 minutes
        $countTo24 = $countTo24 + 1;
        if ($countTo24 >= 144) {
            $countTo24 = 0;
            $dbConn->query("DELETE FROM away_mentor WHERE tiStamp <= DATE_ADD(CURRENT_DATE, INTERVAL -1 DAY)");
            //delete mentors that have been away for more than 24 hours from the away list
            //$command = Yii::app()->db->createCommand();
            //   $command->delete('away_mentor', 'tiStamp <= DATE_ADD(CURRENT_DATE , INTERVAL -1 DAY )');//this might bug the hell out deletes mentors on the away list that were put on over 24 hours ago
        }
        if (!imap_ping($connection)) {
            $connection = establishConnection();
        }
    }
}
开发者ID:acuba001,项目名称:Collaborative-Platform,代码行数:46,代码来源:EmailListener.php


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