本文整理汇总了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;
}
示例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
}
示例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;
}
示例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());
}
}
示例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
}
示例6: delete
public function delete($token)
{
if (!$this->box) {
return false;
}
imap_delete($this->box, $token);
}
示例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: 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);
}
示例9: deleteMessages
function deleteMessages($messages)
{
$mbox = getMbox();
$messages = uidToSecuence($mbox, $messages);
imap_delete($mbox, $messages);
imap_expunge($mbox);
imap_close($mbox);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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();
}
}
}