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


PHP imap_savebody函数代码示例

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


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

示例1: check_bounces

 public function check_bounces($db)
 {
     $email_address = $this->settings['bounce_email'];
     // not used
     $email_username = $this->settings['bounce_username'];
     $email_password = $this->settings['bounce_password'];
     $email_host = $this->settings['bounce_host'];
     $email_port = $this->settings['bounce_port'] ? $this->settings['bounce_port'] : 110;
     // pop3
     $mbox = imap_open('{' . $email_host . ':' . $email_port . '/pop3/novalidate-cert}INBOX', $email_username, $email_password) or die(imap_last_error());
     if (!$mbox) {
         // send email letting them know bounce checking failed?
         // meh. later.
         echo 'Failed to connect';
     } else {
         $MC = imap_check($mbox);
         $result = imap_fetch_overview($mbox, "1:{$MC->Nmsgs}", 0);
         foreach ($result as $overview) {
             $this_subject = (string) $overview->subject;
             //echo "#{$overview->msgno} ({$overview->date}) - From: {$overview->from} <br> {$this_subject} <br>\n";
             $tmp_file = tempnam('/tmp/', 'newsletter_bounce');
             // TODO - tmp files for windows hosting.
             imap_savebody($mbox, $tmp_file, $overview->msgno);
             $body = file_get_contents($tmp_file);
             if (preg_match('/Message-ID:\\s*<?Newsletter-(\\d+)-(\\d+)-([A-Fa-f0-9]{32})/imsU', $body, $matches)) {
                 // we have a newsletter message id, check the hash and mark a bounce.
                 //"message_id" => "Newsletter-$send_id-$member_id-".md5("bounce check for $member_id in send $send_id"),
                 $send_id = (int) $matches[1];
                 $member_id = (int) $matches[2];
                 $provided_hash = trim($matches[3]);
                 $real_hash = md5("bounce check for {$member_id} in send {$send_id}");
                 if ($provided_hash == $real_hash) {
                     $sql = "UPDATE " . _DB_PREFIX . "newsletter_member SET `status` = 4, bounce_time = '" . time() . "' WHERE `member_id` = '" . $member_id . "' AND send_id = '" . $send_id . "' AND `status` = 3 LIMIT 1";
                     $res = query($sql, $db);
                     imap_delete($mbox, $overview->msgno);
                 } else {
                     // bad hash, report.
                 }
             }
             unlink($tmp_file);
         }
         imap_expunge($mbox);
         imap_close($mbox);
     }
 }
开发者ID:phpsa,项目名称:CoreCMS,代码行数:45,代码来源:Newsletter.php

示例2: getMail

 /**
  * @param $callback function that is called with parsed mail header + attachments
  */
 function getMail($callback = '', $timeout = 30)
 {
     if (!$this->connect()) {
         echo "ERROR: IMAP connection to " . $this->server . ":" . $this->port . " failed\n";
         return false;
     }
     $folders = imap_listmailbox($this->handle, '{' . $this->server . ':' . $this->port . '}', '*');
     $msginfo = imap_mailboxmsginfo($this->handle);
     //dp('found '.$msginfo->Nmsgs.' messages in mailbox');
     $this->tot_mails = $msginfo->Nmsgs;
     for ($i = 1; $i <= $this->tot_mails; $i++) {
         //dp("Downloading ".$i." of ".$this->tot_mails." ...");
         //XXX hack because retarded imap_fetchbody() dont allow to fetch the whole message
         $fp = fopen('php://temp', 'w');
         imap_savebody($this->handle, $fp, $i);
         rewind($fp);
         $msg = stream_get_contents($fp);
         fclose($fp);
         $mime = new MimeReader();
         $mime->parseMail($msg);
         $this->emails[] = $mime->getAsEMail($i);
     }
     if (!function_exists($callback)) {
         throw new \Exception('ERROR callback function ' . $callback . ' not found');
     }
     call_user_func($callback, $this->emails, $this);
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:30,代码来源:ImapReader.php

示例3: saveMessageToDisk

 /**
  * Save Message with MessageNumber to Disk
  *
  * @param $save_path
  * @return bool
  */
 public function saveMessageToDisk($savePath)
 {
     $res = imap_savebody($this->stream, $savePath, imap_msgno($this->stream, $this->messageNumber));
     return $res;
 }
开发者ID:nmkr,项目名称:imap,代码行数:11,代码来源:Message.php

示例4: mailGet

 /**
     Get a Message
 */
 function mailGet($i)
 {
     // return imap_body($this->_c,$i,FT_PEEK);
     return imap_savebody($this->_c, 'mail', $i, null, FT_PEEK);
 }
开发者ID:WatersideDevelopment,项目名称:imap-move,代码行数:8,代码来源:imap-move.php

示例5: dre_process_messages

/**
 * Read messages from server and save returned emails into DB
 *
 * @param resource $mbox created by dre_connect() (by reference)
 * @param integer the number of messages to process
 * @return boolean true on success
 */
function dre_process_messages(&$mbox, $limit)
{
    //return; // Exit, in development...
    global $Settings;
    global $dre_messages, $dre_emails, $email_cntr, $del_cntr, $is_cron_mode;
    // No execution time limit
    set_max_execution_time(0);
    $email_cntr = 0;
    $del_cntr = 0;
    for ($index = 1; $index <= $limit; $index++) {
        dre_msg('<hr /><h3>Processing message #' . $index . ':</h3>');
        $strbody = '';
        $hasAttachment = false;
        $hasRelated = false;
        // Save email to hard drive, otherwise attachments may take a lot of RAM
        if (!($tmpMIME = tempnam(sys_get_temp_dir(), 'b2evoMail'))) {
            dre_msg(T_('Could not create temporary file.'), true);
            continue;
        }
        imap_savebody($mbox, $tmpMIME, $index);
        // Create random temp directory for message parts
        $tmpDirMIME = dre_tempdir(sys_get_temp_dir(), 'b2evo_');
        $mimeParser = new mime_parser_class();
        $mimeParser->mbox = 0;
        // Set to 0 for parsing a single message file
        $mimeParser->decode_headers = 1;
        $mimeParser->ignore_syntax_errors = 1;
        $mimeParser->extract_addresses = 0;
        $MIMEparameters = array('File' => $tmpMIME, 'SaveBody' => $tmpDirMIME, 'SkipBody' => 1);
        if (!$mimeParser->Decode($MIMEparameters, $decodedMIME)) {
            dre_msg(sprintf('MIME message decoding error: %s at position %d.', $mimeParser->error, $mimeParser->error_position), true);
            rmdir_r($tmpDirMIME);
            unlink($tmpMIME);
            continue;
        } else {
            dre_msg('MIME message decoding successful');
            if (!$mimeParser->Analyze($decodedMIME[0], $parsedMIME)) {
                dre_msg(sprintf('MIME message analyse error: %s', $mimeParser->error), true);
                rmdir_r($tmpDirMIME);
                unlink($tmpMIME);
                continue;
            }
            // Get message $subject and $post_date from headers (by reference)
            if (!dre_process_header($parsedMIME, $subject, $post_date)) {
                // Couldn't process message headers
                rmdir_r($tmpDirMIME);
                unlink($tmpMIME);
                continue;
            }
            // TODO: handle type == "message" recursively
            // sam2kb> For some reason imap_qprint() demages HTML text... needs more testing
            if ($parsedMIME['Type'] == 'html') {
                // Mail is HTML
                dre_msg('HTML message part saved as ' . $parsedMIME['DataFile']);
                $html_body = file_get_contents($parsedMIME['DataFile']);
                foreach ($parsedMIME['Alternative'] as $alternative) {
                    // First try to get HTML alternative (when possible)
                    if ($alternative['Type'] == 'html') {
                        // HTML text
                        dre_msg('HTML alternative message part saved as ' . $alternative['DataFile']);
                        // sam2kb> TODO: we may need to use $html_body here instead
                        $strbody = file_get_contents($alternative['DataFile']);
                        break;
                        // stop after first alternative
                    } elseif ($alternative['Type'] == 'text') {
                        // Plain text
                        dre_msg('Text alternative message part saved as ' . $alternative['DataFile']);
                        $strbody = imap_qprint(file_get_contents($alternative['DataFile']));
                        break;
                        // stop after first alternative
                    }
                }
            } elseif ($parsedMIME['Type'] == 'text') {
                // Mail is plain text
                dre_msg('Plain-text message part saved as ' . $parsedMIME['DataFile']);
                $strbody = imap_qprint(file_get_contents($parsedMIME['DataFile']));
            } elseif ($parsedMIME['Type'] == 'delivery-status') {
                // Mail is delivery-status
                $strbody = '';
                foreach ($decodedMIME[0]['Parts'] as $part) {
                    $strbody .= imap_qprint(file_get_contents($part['BodyFile']));
                }
            }
            if (count($mimeParser->warnings) > 0) {
                dre_msg(sprintf('<h4>%d warnings during decode:</h4>', count($mimeParser->warnings)));
                foreach ($mimeParser->warnings as $k => $v) {
                    dre_msg('Warning: ' . $v . ' at position ' . $k);
                }
            }
        }
        unlink($tmpMIME);
        if (empty($html_body)) {
            // Plain text message
//.........这里部分代码省略.........
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:101,代码来源:_decode_returned_emails.funcs.php

示例6: pbm_process_messages

/**
 * Read messages from server and create posts
 *
 * @param resource $mbox created by pbm_connect() (by reference)
 * @param integer the number of messages to process
 * @return boolean true on success
 */
function pbm_process_messages(&$mbox, $limit)
{
    global $Settings;
    global $pbm_item_files, $pbm_messages, $pbm_items, $post_cntr, $del_cntr, $is_cron_mode;
    // No execution time limit
    set_max_execution_time(0);
    // Are we in test mode?
    $test_mode_on = $Settings->get('eblog_test_mode');
    $post_cntr = 0;
    $del_cntr = 0;
    for ($index = 1; $index <= $limit; $index++) {
        pbm_msg('<hr /><h3>Processing message #' . $index . ':</h3>');
        $strbody = '';
        $hasAttachment = false;
        $hasRelated = false;
        $pbm_item_files = array();
        // reset the value for each new Item
        // Save email to hard drive, otherwise attachments may take a lot of RAM
        if (!($tmpMIME = tempnam(sys_get_temp_dir(), 'b2evoMail'))) {
            pbm_msg(T_('Could not create temporary file.'), true);
            continue;
        }
        imap_savebody($mbox, $tmpMIME, $index);
        // Create random temp directory for message parts
        $tmpDirMIME = pbm_tempdir(sys_get_temp_dir(), 'b2evo_');
        $mimeParser = new mime_parser_class();
        $mimeParser->mbox = 0;
        // Set to 0 for parsing a single message file
        $mimeParser->decode_headers = 1;
        $mimeParser->ignore_syntax_errors = 1;
        $mimeParser->extract_addresses = 0;
        $MIMEparameters = array('File' => $tmpMIME, 'SaveBody' => $tmpDirMIME, 'SkipBody' => 1);
        if (!$mimeParser->Decode($MIMEparameters, $decodedMIME)) {
            pbm_msg(sprintf('MIME message decoding error: %s at position %d.', $mimeParser->error, $mimeParser->error_position), true);
            rmdir_r($tmpDirMIME);
            unlink($tmpMIME);
            continue;
        } else {
            pbm_msg('MIME message decoding successful');
            if (!$mimeParser->Analyze($decodedMIME[0], $parsedMIME)) {
                pbm_msg(sprintf('MIME message analyse error: %s', $mimeParser->error), true);
                rmdir_r($tmpDirMIME);
                unlink($tmpMIME);
                continue;
            }
            // Get message $subject and $post_date from headers (by reference)
            if (!pbm_process_header($parsedMIME, $subject, $post_date)) {
                // Couldn't process message headers
                rmdir_r($tmpDirMIME);
                unlink($tmpMIME);
                continue;
            }
            // TODO: handle type == "message" recursively
            // sam2kb> For some reason imap_qprint() demages HTML text... needs more testing
            if ($parsedMIME['Type'] == 'html') {
                // Mail is HTML
                if ($Settings->get('eblog_html_enabled')) {
                    // HTML posting enabled
                    pbm_msg('HTML message part saved as ' . $parsedMIME['DataFile']);
                    $html_body = file_get_contents($parsedMIME['DataFile']);
                }
                foreach ($parsedMIME['Alternative'] as $alternative) {
                    // First try to get HTML alternative (when possible)
                    if ($alternative['Type'] == 'html' && $Settings->get('eblog_html_enabled')) {
                        // HTML text
                        pbm_msg('HTML alternative message part saved as ' . $alternative['DataFile']);
                        // sam2kb> TODO: we may need to use $html_body here instead
                        $strbody = file_get_contents($alternative['DataFile']);
                        break;
                        // stop after first alternative
                    } elseif ($alternative['Type'] == 'text') {
                        // Plain text
                        pbm_msg('Text alternative message part saved as ' . $alternative['DataFile']);
                        $strbody = imap_qprint(file_get_contents($alternative['DataFile']));
                        break;
                        // stop after first alternative
                    }
                }
            } elseif ($parsedMIME['Type'] == 'text') {
                // Mail is plain text
                pbm_msg('Plain-text message part saved as ' . $parsedMIME['DataFile']);
                $strbody = imap_qprint(file_get_contents($parsedMIME['DataFile']));
            }
            // Check for attachments
            if (!empty($parsedMIME['Attachments'])) {
                $hasAttachment = true;
                foreach ($parsedMIME['Attachments'] as $file) {
                    pbm_msg('Attachment: ' . $file['FileName'] . ' stored as ' . $file['DataFile']);
                }
            }
            // Check for inline images
            if (!empty($parsedMIME['Related'])) {
                $hasRelated = true;
//.........这里部分代码省略.........
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:101,代码来源:_post_by_mail.funcs.php

示例7: imap_savebody_alt

 /**
  * define proxy function for imap_savebody
  *
  * @param resource $imap_stream
  * @param mixed $file
  * @param int $msg_number
  * @param string $part_number
  * @param int $options
  * @return boolean
  */
 function imap_savebody_alt($imap_stream, $file, $msg_number, $part_number = null, $options = null)
 {
     return imap_savebody($imap_stream, $file, $msg_number, $part_number, $options);
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:14,代码来源:functions.php

示例8: mailGetPart

 function mailGetPart($i, $part = '1', $file = null)
 {
     $this->_open();
     return imap_savebody($this->_c, $file, $mnum, $part, FT_INTERNAL | FT_PEEK);
 }
开发者ID:edoceo,项目名称:radix,代码行数:5,代码来源:IMAP.php

示例9: foreach

                            $attachments[$partid][pos] = $partid + 1;
                            $attachments[$partid][id] = $postid;
                        }
                    }
                }
            }
            if ($attachments) {
                foreach ($attachments as $attachment) {
                    $filename = '/tmp/' . $attachment[filename];
                    $filelist[] = str_replace('7z', 'xml', $filename);
                    $file = fopen($filename, 'w');
                    stream_filter_append($file, 'convert.base64-decode', STREAM_FILTER_WRITE);
                    if (chkconfig($cashimport['use_seen_flag'])) {
                        imap_savebody($ih, $file, $attachment[id], $attachment[pos]);
                    } else {
                        imap_savebody($ih, $file, $attachment[id], $attachment[pos], FT_PEEK);
                    }
                    exec('7za e ' . $filename . ' -p' . $cashimport['7zpasswd'] . ' -o/tmp -y', $debug);
                    fclose($file);
                }
            }
        }
    }
    imap_close($ih);
}
if (!empty($filelist)) {
    $count = sizeof($filelist);
    $cash = array();
    $time = time();
    if (isset($cashimport['copy_dir']) && !empty($cashimport['copy_dir'])) {
        for ($i = 0; $i < $count; $i++) {
开发者ID:Kliwer,项目名称:lms,代码行数:31,代码来源:cashimport-alior-xml.php

示例10: saveAs

 /**
  * This function saves the attachment to the exact specified location.
  *
  * @param  string $path
  * @return bool
  */
 public function saveAs($path)
 {
     $dirname = dirname($path);
     if (file_exists($path)) {
         if (!is_writable($path)) {
             return false;
         }
     } elseif (!is_dir($dirname) || !is_writable($dirname)) {
         return false;
     }
     if (($filePointer = fopen($path, 'w')) == false) {
         return false;
     }
     switch ($this->encoding) {
         case 3:
             //base64
             $streamFilter = stream_filter_append($filePointer, 'convert.base64-decode', STREAM_FILTER_WRITE);
             break;
         case 4:
             //quoted-printable
             $streamFilter = stream_filter_append($filePointer, 'convert.quoted-printable-decode', STREAM_FILTER_WRITE);
             break;
         default:
             $streamFilter = null;
     }
     $result = imap_savebody($this->imapStream, $filePointer, $this->messageId, $this->partId ?: 1, FT_UID);
     if ($streamFilter) {
         stream_filter_remove($streamFilter);
     }
     fclose($filePointer);
     return $result;
 }
开发者ID:rochefort8,项目名称:tt85,代码行数:38,代码来源:Attachment.php

示例11: scanMailbox

 /**
  * Scan mailbox to import news.
  */
 private function scanMailbox()
 {
     // check available emails
     $count = imap_num_msg($this->mailbox);
     $this->report .= sprintf($GLOBALS['TL_LANG']['tl_zad_sendnews']['inf_msgs'] . '<br />', $count);
     for ($msg = 1; $msg <= $count; $msg++) {
         // init
         $this->header = null;
         $this->forwarded = null;
         $this->text = null;
         $this->html = null;
         $this->attach = array();
         $this->images = array();
         // read header
         $this->readHeader($msg);
         $this->report .= sprintf($GLOBALS['TL_LANG']['tl_zad_sendnews']['inf_nummsg'] . '<br />', $msg, $this->header->subject);
         if ($this->header->Deleted == 'D') {
             // skip deleted emails
             $this->report .= '&nbsp;&nbsp;&nbsp;&nbsp;' . $GLOBALS['TL_LANG']['tl_zad_sendnews']['inf_del'] . '<br />';
             continue;
         }
         // read content
         $this->readContent($msg);
         // import news
         $this->importNews();
         // do post action
         if ($this->manager->post_action == 'move') {
             // move email
             $res = imap_mail_move($this->mailbox, $msg, $this->manager->move_mailbox);
             if (!$res) {
                 // error, do nothing
                 $this->log('Can\'t move email ' . $msg . ' to ' . $this->manager->move_mailbox . ' for the sendnews manager \'' . $this->manager->name . '\'', 'ZadSendnewsManager scanMailbox()', TL_ERROR);
                 $this->report .= sprintf($GLOBALS['TL_LANG']['tl_zad_sendnews']['wrn_move'] . '<br />', $msg, $this->manager->move_mailbox);
                 $this->signalWarning();
             }
         } elseif ($this->manager->post_action == 'log') {
             // log and delete email
             $fl = fopen(TL_ROOT . '/system/logs/zad_sendnews_' . $this->manager->id . '.log', 'ab');
             if (!$fl) {
                 // error, do nothing
                 $this->log('Can\'t write log file for the sendnews manager \'' . $this->manager->name . '\'', 'ZadSendnewsManager scanMailbox()', TL_ERROR);
                 $this->report .= sprintf($GLOBALS['TL_LANG']['tl_zad_sendnews']['wrn_open'] . '<br />', $msg);
                 $this->signalWarning();
             } else {
                 fwrite($fl, "\n\n###---[[[EMAIL START]]]---###\n");
                 $res = imap_savebody($this->mailbox, $fl, $msg);
                 if (!$res) {
                     // error, do nothing
                     $this->log('Can\'t log email ' . $msg . ' for the sendnews manager \'' . $this->manager->name . '\'', 'ZadSendnewsManager scanMailbox()', TL_ERROR);
                     $this->report .= sprintf($GLOBALS['TL_LANG']['tl_zad_sendnews']['wrn_write'] . '<br />', $msg);
                     $this->signalWarning();
                 }
                 fclose($fl);
             }
             imap_delete($this->mailbox, $msg);
         } else {
             // delete email
             imap_delete($this->mailbox, $msg);
         }
     }
 }
开发者ID:pandroid,项目名称:contao-zad_sendnews,代码行数:64,代码来源:ZadSendnewsManager.php

示例12: CheckMessage

function CheckMessage($uid, $subject)
{
    $file = "/tmp/imap-{$uid}.msg";
    if (!imap_savebody($GLOBALS["MBXCON"], $file, $uid)) {
        events("Failed save message {$uid}", imap_last_error(), $GLOBALS["ACCOUNT_IMAP"], __LINE__);
        return false;
    }
    $datas = @file_get_contents($file);
    if (preg_match("#The following addresses failed:\\s+<(.+?)>#is", $datas, $re)) {
        if (preg_match("#(.+?)@(.+?)>#", $re[1], $ri)) {
            $re[1] = "{$ri[1]}@{$ri[2]}";
        }
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
        $GLOBALS["FOUND_BAD_MAIL"]["{$re['1']}"] = true;
        return true;
    }
    if (preg_match("#Return Receipt#", $datas, $re)) {
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
    }
    if (preg_match("#Final-Recipient: rfc822;.+?\\s+Action: delayed#", $datas, $re)) {
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
    }
    if (preg_match("#delivery temporarily suspended#", $datas, $re)) {
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
    }
    if (preg_match("#said: 550 5\\.1\\.1 <(.+?)>: Recipient address rejected#is", $datas, $re)) {
        if (preg_match("#(.+?)@(.+?)>#", $re[1], $ri)) {
            $re[1] = "{$ri[1]}@{$ri[2]}";
        }
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
        $GLOBALS["FOUND_BAD_MAIL"]["{$re['1']}"] = true;
        return true;
    }
    if (preg_match("#R=E9ponse automatique d'absence du bureau#i", $datas, $re)) {
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
        return true;
    }
    if (preg_match("#Je suis absent entre#", $datas, $re)) {
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
        return true;
    }
    if (preg_match("#Je suis en cong.+?du#", $datas, $re)) {
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
        return true;
    }
    if (preg_match("#550\\s+<(.+?)>: User unknown#", $datas, $re)) {
        if (preg_match("#(.+?)@(.+?)>#", $re[1], $ri)) {
            $re[1] = "{$ri[1]}@{$ri[2]}";
        }
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
        $GLOBALS["FOUND_BAD_MAIL"]["{$re['1']}"] = true;
        return true;
    }
    if (preg_match("#550\\s+<(.+?)>: Recipient address\\s+rejected#", $datas, $re)) {
        if (preg_match("#(.+?)@(.+?)>#", $re[1], $ri)) {
            $re[1] = "{$ri[1]}@{$ri[2]}";
        }
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
        $GLOBALS["FOUND_BAD_MAIL"]["{$re['1']}"] = true;
        return true;
    }
    if (preg_match("#550 5\\.1\\.1 <(.+?)>: Recipient\\s+address rejected:#", $datas, $re)) {
        if (preg_match("#(.+?)@(.+?)>#", $re[1], $ri)) {
            $re[1] = "{$ri[1]}@{$ri[2]}";
        }
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
        $GLOBALS["FOUND_BAD_MAIL"]["{$re['1']}"] = true;
        return true;
    }
    if (preg_match("#<(.+?)>: Host or domain name not found#", $datas, $re)) {
        if (preg_match("#(.+?)@(.+?)>#", $re[1], $ri)) {
            $re[1] = "{$ri[1]}@{$ri[2]}";
        }
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
        $GLOBALS["FOUND_BAD_MAIL"]["{$re['1']}"] = true;
        return true;
    }
    if (preg_match("#<mailto:(.+?)>\\s+The recipient's e-mail address was not found#", $datas, $re)) {
        if (preg_match("#(.+?)@(.+?)>#", $re[1], $ri)) {
            $re[1] = "{$ri[1]}@{$ri[2]}";
        }
        @unlink($file);
        @imap_delete($GLOBALS["MBXCON"], "{$uid}:{$uid}");
        $GLOBALS["FOUND_BAD_MAIL"]["{$re['1']}"] = true;
        return true;
    }
    if (preg_match("#<(.+?)>: host .+?said: 550.+?5\\.1\\.0\\s+Address rejected#", $datas, $re)) {
        if (preg_match("#(.+?)@(.+?)>#", $re[1], $ri)) {
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.emailing.badmails.php

示例13: check_bounces

 public static function check_bounces($debug = false)
 {
     $email_username = module_config::c('newsletter_bounce_username', '');
     $email_password = module_config::c('newsletter_bounce_password', '');
     $email_host = module_config::c('newsletter_bounce_host', '');
     $email_port = module_config::c('newsletter_bounce_port', '110');
     $email_ssl = module_config::c('newsletter_bounce_ssl', '/ssl');
     if (!$email_username || !$email_password || !$email_host || !$email_port) {
         if ($debug) {
             echo "No username, password, host or port defined. Please check settings.\n";
         }
         return;
     }
     $connect_string = '{' . $email_host . ':' . $email_port . $email_ssl . '/pop3/novalidate-cert}INBOX';
     if ($debug) {
         echo "Connecting using: " . $connect_string . "\n\n";
     }
     $mbox = imap_open($connect_string, $email_username, $email_password, 0, 1);
     // or die();
     if (!$mbox) {
         // send email letting them know bounce checking failed?
         // meh. later.
         echo 'Failed to connect';
         echo print_r(imap_errors());
     } else {
         $MC = imap_check($mbox);
         $result = imap_fetch_overview($mbox, "1:{$MC->Nmsgs}", 0);
         foreach ($result as $overview) {
             if ($debug) {
                 $this_subject = (string) $overview->subject;
                 echo "\n\n--------------------------------------------------\nFound an email! \n";
                 echo "   Subject: {$this_subject}\n";
                 echo "   #{$overview->msgno} ({$overview->date}) - From: {$overview->from} \n";
             }
             if (is_dir(_UCM_FOLDER . "/temp/") && is_writable(_UCM_FOLDER . "/temp/")) {
                 $tmp_file = tempnam(_UCM_FOLDER . "/temp/", 'newsletter_bounce');
             } else {
                 $tmp_file = tempnam(sys_get_temp_dir(), 'newsletter_bounce');
             }
             imap_savebody($mbox, $tmp_file, $overview->msgno);
             $body = file_get_contents($tmp_file);
             $this_is_a_bounce = false;
             if (preg_match('/Message-ID:\\s*<?Newsletter-(\\d+)-(\\d+)-(\\d+)-([A-Fa-f0-9]{32})/imsU', $body, $matches)) {
                 // we have a newsletter message id, check the hash and mark a bounce.
                 $newsletter_id = (int) $matches[1];
                 $send_id = (int) $matches[2];
                 $newsletter_member_id = (int) $matches[3];
                 $provided_hash = trim($matches[4]);
                 if ($debug) {
                     echo "  this is a bounce newsletter. ID: {$newsletter_id} SEND: {$send_id}, Member: {$newsletter_member_id} \n";
                 }
                 $real_hash = self::generate_bounce_message_id($newsletter_id, $send_id, $newsletter_member_id, true);
                 if ($provided_hash == $real_hash) {
                     $this_is_a_bounce = true;
                     // YAY! valid bounce!
                     // have to update the newsletter_member with an extra bounce_count.
                     //$newsletter_member = get_single('newsletter_member','newsletter_member_id',$newsletter_member_id);
                     //if($newsletter_member && $newsletter_member['newsletter_member_id'] == $newsletter_member_id){
                     // found the member! increment count.
                     $sql = "UPDATE `" . _DB_PREFIX . "newsletter_member` SET bounce_count = bounce_count + 1 WHERE newsletter_member_id = " . (int) $newsletter_member_id . " LIMIT 1";
                     query($sql);
                     //}
                     // have to update newsletter_send_member with a bounce timestamp.
                     $sql = "UPDATE " . _DB_PREFIX . "newsletter_send_member SET `status` = " . _NEWSLETTER_STATUS_BOUNCED . ", bounce_time = '" . time() . "' WHERE `newsletter_member_id` = '" . $newsletter_member_id . "' AND send_id = '" . $send_id . "' LIMIT 1";
                     query($sql);
                 } else {
                     if ($debug) {
                         echo "   WOA! Hash doesn't match, this is a big problem. Get in touch with dtbaker. \n";
                         echo "    " . $matches[0] . " with \n";
                         echo "    " . $real_hash . "\n";
                     }
                     // bad hash, or no hash found, report this so the user can login manually and review the bounced message.
                 }
             }
             if (!$this_is_a_bounce) {
                 // didn't find a bounce using message ID hash.
                 // this can be because we're sending through google.
                 // look for the subject fields.
                 if ($debug) {
                     echo '    - no bounce message id found, checking for "delivery failure" message' . "\n";
                 }
                 if ((preg_match('#Delivery.*Failure#i', $body) || preg_match('#Delivery.*Failed#i', $body) || preg_match('#Failed.*Delivery#i', $body)) && preg_match_all('#Subject: (.*)#', $body, $subject_matches)) {
                     if ($debug) {
                         echo '    - FOUND DELIVERY FAILURE' . "\n";
                     }
                     // find who this newsletter was sent to
                     $to_emails = array();
                     if (preg_match_all('#To: (.*)#', $body, $to_matches)) {
                         foreach ($to_matches[1] as $possible_to_email) {
                             // todo: ignore the "To" address of the original sender email in newsletter table,
                             $possible_to_email = str_replace('<', ' ', $possible_to_email);
                             $possible_to_email = str_replace('>', ' ', $possible_to_email);
                             foreach (explode(' ', $possible_to_email) as $token) {
                                 if ($debug) {
                                     echo '    - parsing email:' . $token . "\n";
                                 }
                                 $email = filter_var(filter_var($token, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL);
                                 if ($email !== false) {
                                     if ($debug) {
                                         echo '    - checking for local member:' . $email . "\n";
//.........这里部分代码省略.........
开发者ID:sgh1986915,项目名称:php-crm,代码行数:101,代码来源:newsletter.php

示例14: saveAs

 /**
  * This function saves the attachment to the exact specified location.
  *
  * @param  string $path
  * @return bool
  */
 public function saveAs($path)
 {
     $dirName = dirname($path);
     if (file_exists($path)) {
         if (!is_writable($path)) {
             return false;
         }
     } elseif (!is_dir($dirName) || !is_writable($dirName)) {
         return false;
     }
     if (($filePointer = fopen($path, 'w')) == false) {
         return false;
     }
     switch ($this->encoding) {
         case 3:
             //base64
             $streamFilter = stream_filter_append($filePointer, 'convert.base64-decode', STREAM_FILTER_WRITE);
             break;
         case 4:
             //quoted-printable
             $streamFilter = stream_filter_append($filePointer, 'convert.quoted-printable-decode', STREAM_FILTER_WRITE);
             break;
         default:
             $streamFilter = null;
     }
     // Fix an issue causing server to throw an error
     // See: https://github.com/tedious/Fetch/issues/74 for more details
     imap_fetchbody($this->imapStream, $this->messageId, $this->partId ?: 1, FT_UID);
     $result = imap_savebody($this->imapStream, $filePointer, $this->messageId, $this->partId ?: 1, FT_UID);
     if ($streamFilter) {
         stream_filter_remove($streamFilter);
     }
     fclose($filePointer);
     return $result;
 }
开发者ID:apexwire,项目名称:fetch,代码行数:41,代码来源:Attachment.php

示例15: imap_savebody

<?php

echo "Checking with no parameters\n";
imap_savebody();
echo "Checking with incorrect parameter type\n";
imap_savebody('');
imap_savebody(false);
require_once dirname(__FILE__) . '/imap_include.inc';
$stream_id = setup_test_mailbox('', 1);
imap_savebody($stream_id);
$file = dirname(__FILE__) . '/tmpsavebody.txt';
//with URL
$z = imap_savebody($stream_id, $file, 1);
var_dump($z);
echo "Size: " . filesize($file) . "\n";
//With FOPEN
$fp = fopen($file, 'w');
$z = imap_savebody($stream_id, $fp, 1);
fclose($fp);
var_dump($z);
echo "Size: " . filesize($file) . "\n";
imap_close($stream_id);
@unlink(dirname(__FILE__) . '/tmpsavebody.txt');
require_once 'clean.inc';
开发者ID:badlamer,项目名称:hhvm,代码行数:24,代码来源:imap_savebody_basic.php


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