Beispiel #1
1
 public function messages($options = true)
 {
     if (is_bool($options)) {
         $options = array('seen' => $options);
     }
     $options = self::options($options, array('offset' => 0, 'limit' => 0, 'seen' => true, 'newestFirst' => true));
     $IMAPMessageClass = $this->IMAPMessageClass;
     $headers = imap_headers($this->mbox);
     if ($options['newestFirst']) {
         $headers = array_reverse($headers);
     }
     $messages = array();
     $eligables = 0;
     foreach ($headers as $n => $header) {
         if (preg_match('/(U?)\\s+(\\d+)\\)/', $header, $match)) {
             $unseen = (bool) trim($match[1]);
             $msgNum = (int) $match[2];
             $eligable = $options['seen'] || $unseen;
             if ($eligable) {
                 $eligables++;
             }
             if ($eligable) {
                 if ($eligables > $options['offset']) {
                     if (!$options['limit'] || !isset($messages[$options['limit'] - 1])) {
                         $messages[] = new $IMAPMessageClass($this, $msgNum, $header, $unseen);
                     }
                 }
             }
             if ($options['limit'] && isset($messages[$options['limit'] - 1])) {
                 break;
             }
         }
     }
     return $messages;
 }
Beispiel #2
1
 public function free($util)
 {
     $stream = imap_open("{imap.club-internet.fr:993/imap/SSL}", $util, "wrasuxwr");
     var_dump($stream);
     $check = imap_check($stream);
     $list = imap_list($stream, "{imap.club-internet.fr}", "*");
     imap_createmailbox($stream, '{imap.club-internet.fr}brubru');
     $getmailboxes = imap_getmailboxes($stream, "{imap.club-internet.fr}", "*");
     $headers = imap_headers($stream);
     $num_msg = imap_num_msg($stream);
     $status = imap_status($stream, "{imap.club-internet.fr:993/imap/SSL}INBOX", SA_ALL);
     $messages = imap_fetch_overview($stream, "1:" . $num_msg);
     $structure = imap_fetchstructure($stream, 2);
     $body = utf8_encode(quoted_printable_decode(imap_body($stream, '2')));
     // imap_delete($stream, '1');
     // imap_expunge($stream);
     return view('Imap.Imap')->with(compact('resource'))->with(compact('check'))->with(compact('list'))->with(compact('getmailboxes'))->with(compact('headers'))->with(compact('num_msg'))->with(compact('status'))->with(compact('errors'))->with(compact('messages'))->with(compact('structure'))->with(compact('body'));
 }
 public function total()
 {
     if (!$this->box) {
         return 0;
     } else {
         return count(imap_headers($this->box));
     }
 }
Beispiel #4
0
 function imapcount()
 {
     if (!$this->mbox) {
         return false;
     }
     $headers = imap_headers($this->mbox);
     return count($headers);
 }
 function __imap_count_mail()
 {
     $this->headers = @imap_headers($this->conn);
     if (!empty($this->headers)) {
         return sizeof($this->headers);
     } else {
         return $this->imap_get_last_error();
     }
 }
Beispiel #6
0
 function listMessages()
 {
     return imap_headers($this->stream);
 }
 function getTotalMails()
 {
     $headers = imap_headers($this->marubox);
     return count($headers);
 }
<?php

// open IMAP connection
$mail = imap_open('{mail.server.com:143}', 'username', 'password');
// or, open POP3 connection
$mail = imap_open('{mail.server.com:110/pop3}', 'username', 'password');
// grab a list of all the mail headers
$headers = imap_headers($mail);
// grab a header object for the last message in the mailbox
$last = imap_num_msg($mail);
$header = imap_header($mail, $last);
// grab the body for the same message
$body = imap_body($mail, $last);
// close the connection
imap_close($mail);
function cw_order_messages_get_emails($time, $prev_time)
{
    global $tables, $config;
    global $take_messages_debug;
    /*
    $config['order_messages']['contact_email_access_info'] = '{pop.gmail.com:995/novalidate-cert/pop3/ssl}INBOX';
    */
    $mail = imap_open($config['order_messages']['contact_email_access_info'], $config['order_messages']['contact_email_address'], $config['order_messages']['contact_email_password']);
    /*cw_log_add("order_messages_get_emails",array('contact_email_access_info'=>$config['order_messages']['contact_email_access_info'],
      'contact_email_address'=>$config['order_messages']['contact_email_address'],
      'contact_email_password'=>'--hidden--'));*/
    if (!$mail) {
        //cw_log_add("order_messages_get_emails", array("imap last error: "=>imap_last_error()));
        if ($take_messages_debug == 'Y') {
            print_r(array("order_messages_get_emails", array("imap last error: " => imap_last_error())));
            print "<br>";
        }
    } else {
        if ($take_messages_debug == 'Y') {
            print_r(array("order_messages_get_emails", array("imap last error: " => imap_last_error(), "mail_obj" => $mail)));
            print "<br>";
        }
    }
    $last_mail_id = cw_query_first_cell("select max(mail_id) from {$tables['mail_rpool']}");
    if ($mail) {
        $headers = imap_headers($mail);
        if (!empty($headers)) {
            $curr_message_id = imap_num_msg($mail);
            while ($curr_message_id > 0) {
                $header = imap_header($mail, $curr_message_id);
                //do not save emails from anyone else but users
                $from = $header->from;
                foreach ($from as $id => $object) {
                    $emailfrom = $object->mailbox . "@" . $object->host;
                }
                $is_users_email = cw_query_first_cell("select count(*) from {$tables['customers']} where email='" . addslashes($emailfrom) . "'");
                if (!$is_users_email) {
                    $curr_message_id--;
                    continue;
                }
                // pull the plain text for message $n
                $st = imap_fetchstructure($mail, $curr_message_id);
                if (!empty($st->parts)) {
                    for ($i = 0, $j = count($st->parts); $i < $j; $i++) {
                        $part = $st->parts[$i];
                        if ($part->subtype == 'PLAIN') {
                            $body = imap_fetchbody($mail, $curr_message_id, $i + 1);
                        }
                    }
                } else {
                    $body = imap_body($mail, $curr_message_id);
                }
                $body = preg_replace('#(^\\w.+:\\n)?(^>.*(\\n|$))+#mi', "", $body);
                cw_array2insert('mail_rpool', array('header' => serialize($header), 'body' => addslashes($body), 'subject' => $header->subject, 'mail_from' => addslashes($emailfrom), 'mail_to' => $header->toaddress));
                cw_log_add('mail_rpool', array('header' => $header, 'subject' => $header->subject, 'mail_from' => $emailfrom, 'mail_to' => $header->toaddress, 'body' => $body));
                $curr_message_id--;
            }
        }
        imap_close($mail);
    }
    if ($last_mail_id) {
        $last_mail_id_condition = " where mail_id > '{$last_mail_id}' ";
    }
    if ($take_messages_debug != 'Y') {
        cw_order_messages_process_new_emails($last_mail_id_condition);
    }
    return;
}
Beispiel #10
0
 /**
  * Used to get total unread mail from that mailbox
  *
  * @return an integer (Total Mail)
  **/
 function getTotalMails()
 {
     //Get Total Number off Unread Email In Mailbox
     $headers = imap_headers($this->marubox);
     return count($headers);
 }
Beispiel #11
0
         } else {
             echo 'Не удалось открыть ящик';
         }
     }
     // if
     break;
     //////////////////////////////////////////////////
 //////////////////////////////////////////////////
 case 'mailboxes':
     // нет параметров
 // нет параметров
 case 'headers':
     // нет параметров
     //////////////////////////////////////////////////
     if ($mbi) {
         $r = $cmd == 'mailboxes' ? imap_listmailbox($mbi, $ibox['mailbox'], '*') : imap_headers($mbi);
         if ($r) {
             while (list($key, $val) = each($r)) {
                 echo "{$val}\n";
             }
         } else {
             echo 'Не получилось';
         }
     }
     // if
     break;
     //////////////////////////////////////////////////
 //////////////////////////////////////////////////
 case 'header':
     // $params - номер письма
     //////////////////////////////////////////////////
 /**
  * liefert die Mailheader
  * @return array
  */
 public function imapHeaders()
 {
     if ($this->imap === null) {
         throw new IMAPException(__METHOD__ . ' not connected');
     }
     $this->imapPing(true);
     return imap_headers($this->imap);
 }
function get_list($imap)
{
    // get the list of messages in this mailbox
    $headers = imap_headers($imap);
    $messages = sizeof($headers);
    for ($i = 0; $i < $messages; $i++) {
        echo $headers[$i];
    }
    imap_close($imap);
}
 function getNumUnreadEmails()
 {
     $headers = imap_headers($this->mailbox);
     return count($headers);
 }
Beispiel #15
0
 /**
  * Get Total Number off Unread Email In Mailbox
  * @return bool|int
  */
 public function getTotalMails()
 {
     if (!$this->marubox) {
         return false;
     } else {
         $headers = imap_headers($this->marubox);
         return count($headers);
     }
 }
function display_list($auth_user, $accountid)
{
    // show the list of messages in this mailbox
    global $table_width;
    if (!$accountid) {
        echo 'No mailbox selected<br /><br /><br /><br /><br /><br />.';
    } else {
        $imap = open_mailbox($auth_user, $accountid);
        if ($imap) {
            echo "<table width = {$table_width} cellspacing = 0 \n                   cellpadding = 6  border = 0>";
            $headers = imap_headers($imap);
            // we could reformat this data, or get other details using
            // imap_fetchheaders, but this is not a bad summary so we just echo each
            $messages = sizeof($headers);
            for ($i = 0; $i < $messages; $i++) {
                echo '<tr><td bgcolor = "';
                if ($i % 2) {
                    echo '#ffffff';
                } else {
                    echo '#ffffcc';
                }
                echo '"><a href ="index.php?action=view-message&messageid=' . ($i + 1) . '">';
                echo $headers[$i];
                echo "</a></td></tr>\n";
            }
            echo '</table>';
        } else {
            $account = get_account_settings($auth_user, $accountid);
            echo 'could not open mail box ' . $account['server'] . '.<br /><br /><br /><br />';
        }
    }
}
Beispiel #17
0
function display_list($auth_user, $accountid)
{
    //    echo "Debug: display_list()<br />";
    global $table_width;
    //debug $accountid -> $accountid[0]
    $counter = 0;
    //    echo "Debug: counter: ".$counter."<br />";
    if (!$accountid) {
        echo "<p style=\"padding-bottom: 100px\">Mailbox is not selected.</p>";
    } else {
        $imap = open_mailbox($auth_user, $accountid);
        if ($imap) {
            echo "<table width=\"" . $table_width . "\" cellspacing=\"0\"\n                cellpadding=\"6\" border=\"0\">";
            $headers = imap_headers($imap);
            $messages = sizeof($headers);
            for ($i = 0; $i < $messages; $i++) {
                echo "<tr><td bgcolor=\"";
                if ($i % 2) {
                    echo '#ffffff';
                } else {
                    echo '#ffffcc';
                }
                echo "\"><a href=\"index.php?action=view-message&messageid=" . ($i + 1) . "\">";
                echo $headers[$i];
                echo "</a></td></tr>\n";
            }
            echo "</table>";
        } else {
            $account = get_account_settings($auth_user, $accountid);
            echo "<p style=\"padding-bottom: 100px\">Can\\'t open mailbox" . $account['server'] . ".</p>";
        }
    }
}
Beispiel #18
0
 <?php 
$mb = imap_open("{my.imap.com.tw}INBOX", "wilson", "mypasswd");
$AllHeaders = imap_headers($mb);
imap_close($mb);
echo "<pre>\n";
for ($i = 0; $i < count($AllHeaders); $i++) {
    echo $AllHeaders[$i] . "<p><hr><p>\n";
}
echo "</pre>\n";
?>
 
Beispiel #19
0
    if (!empty($cc)) {
        $headers .= "Cc: " . $cc . "\r\n";
    }
    if (strstr(strtolower($body), "<html>") !== False) {
        $headers = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    }
    mail($to, $subject, $body, $headers);
    $output .= "<div align=center><b>Message sent</b></div>";
    $_REQUEST['folder'] = $_REQUEST['mbox'];
}
if (isset($_REQUEST['folder'])) {
    $output .= "<a href=\"index.php\">Back</a><br />";
    $mb = imap_open($server . $_REQUEST['folder'], $user, $pass);
    $n = imap_num_msg($mb);
    imap_headers($mb);
    $output .= "<table cellspacing=0 cellpadding=4 border=1>";
    for ($i = $n; $i > 0; $i--) {
        $h = imap_header($mb, $i);
        $output .= "<tr";
        if ($h->Unseen == 'U' || $h->Recent == 'N') {
            $output .= " class=\"unread\"";
        }
        $output .= ">";
        $output .= "<td>" . date("n/d/y g:ia", $h->udate) . "</td>";
        $output .= "<td>" . $h->fromaddress . "</td>";
        $output .= sprintf("<td><a href=\"index.php?mbox=%s&msg=%d\">%s</a></td>", $_REQUEST['folder'], $i, $h->subject);
        $output .= "</tr>";
    }
    $output .= "</table>";
} else {
Beispiel #20
0
 /**
  * Returns an array containing summary information about the messages.
  * Use this function to list messages without downloading the entire
  * contents of each one
  * @return Array
  */
 function GetQuickHeaders()
 {
     return imap_headers($this->mbox);
 }
<?php

use rdx\imap\IMAPMailbox;
require 'env.php';
require 'autoload.php';
header('Content-type: text/plain');
$mbox = new IMAPMailbox(IMAP_HELPDESK_HOST, IMAP_HELPDESK_USER, IMAP_HELPDESK_PASS, 'INBOX', ['novalidate-cert']);
print_r($mbox->headers());
$messages = $mbox->messages();
var_dump(count($messages));
print_r($messages);
exit;
$headers = imap_headers($mbox);
print_r($headers);
foreach ($headers as $hd) {
    if (preg_match('/(\\d+)\\)/', $hd, $match)) {
        $msgNum = $match[1];
        $hd = imap_headerinfo($mbox, $msgNum);
        $new = !!trim($hd->Unseen);
        if ($new) {
            // subject -- should contain #code#
            $title = get_plain_text_subject($mbox, $msgNum, $hd);
            $code = preg_match('/#(\\d+)#$/', $title, $match) ? (int) $match[1] : 0;
            echo $title . "\n";
            // body -- get only last part (no conversation history)
            $attachments = array();
            $full_body = get_plain_text_body($mbox, $msgNum, $attachments);
            $body = get_last_body_part($full_body);
            if ($attachments) {
                $body .= "\n\n== Attachments:\n* " . implode("\n* ", $attachments);
            }
Beispiel #22
0
 public function imap_unread()
 {
     //$m_gdmy = "20-March-2014";
     //$m_search= imap_search ($this->conn, 'UNSEEN');
     //If mailbox is empty......Display "No New Messages", else........ You got mail....oh joy
     //echo $m_search;
     //echo '<pre>'; print_r($m_search);
     //echo count($m_search); die;
     //$count = (count($m_search) > 0) ? count($m_search) : 0;
     $count = 0;
     if (!$this->conn) {
         echo "Error";
     } else {
         $headers = imap_headers($this->conn);
         foreach ($headers as $mail) {
             $flags = substr($mail, 0, 4);
             $isunr = strpos($flags, "U") !== false;
             if ($isunr) {
                 $count++;
             }
         }
     }
     //echo $count; die;
     $this->close_imap();
     return $count;
 }
Beispiel #23
0
 /**
  * Get Total Number off Unread Email In Mailbox
  * @return bool|int
  */
 public function getTotalMails()
 {
     if (!$this->getMailBox()) {
         return false;
     }
     $headers = imap_headers($this->getMailBox());
     return count($headers);
 }
Beispiel #24
0
 function get_message_list_headers()
 {
     $a = imap_headers($this->IMAP_resource);
     return $a;
 }
Beispiel #25
0
 function fullMailList()
 {
     $mailHeaders = @imap_headers($this->mbox);
     $numEmails = sizeof($mailHeaders);
     $mailOverviews = @imap_fetch_overview($this->mbox, "1:{$numEmails}", 0);
     $out = array("headers" => $mailHeaders, "overview" => $mailOverviews, "count" => $numEmails);
     return $out;
 }
function display_list($auth_user, $accountid)
{
    // show the list of messages in this mailbox
    global $table_width;
    if (!$accountid) {
        echo "<p style=\"padding-bottom: 100px\">No mailbox selected.</p>";
    } else {
        $imap = open_mailbox($auth_user, $accountid);
        if ($imap) {
            echo "<table width=\"" . $table_width . "\" cellspacing=\"0\"\n                   cellpadding=\"6\" border=\"0\">";
            $headers = imap_headers($imap);
            // we could reformat this data, or get other details using
            // imap_fetchheaders, but this is not a bad summary so we just echo each
            $messages = sizeof($headers);
            for ($i = 0; $i < $messages; $i++) {
                echo "<tr><td bgcolor=\"";
                if ($i % 2) {
                    echo "#ffffff";
                } else {
                    echo "#ffffcc";
                }
                echo "\"><a href=\"index.php?action=view-message&messageid=" . ($i + 1) . "\">";
                echo $headers[$i];
                echo "</a></td></tr>\n";
            }
            echo "</table>";
        } else {
            $account = get_account_settings($auth_user, $accountid);
            echo "<p style=\"padding-bottom: 100px\">Could not open mail box " . $account['server'] . ".</p>";
        }
    }
}
 $DB_POP3_host = $POP3_Result['host'];
 $DB_POP3_port = $POP3_Result['port'];
 $DB_POP3_username = $POP3_Result['username'];
 $DB_POP3_password = $POP3_Result['password'];
 $DB_POP3_mailbox = $POP3_Result['mailbox'];
 $DB_HTML_YN = $POP3_Result['HTML_YN'];
 $DB_DeleteYN = $POP3_Result['Delete_After_Download'];
 $DB_SpamHeader = $POP3_Result['Spam_Header'];
 $DB_ConcatMid = $POP3_Result['Concat_Middle'];
 $DB_Mail_Type = $POP3_Result['Mail_Type'];
 if ($DB_Pop_Enabled == 1) {
     $Responder_ID = $DB_Attached_Responder;
     $conn = @imap_open("\\{{$DB_POP3_host}:{$DB_POP3_port}/{$DB_Mail_Type}/notls}{$DB_POP3_mailbox}", $DB_POP3_username, $DB_POP3_password);
     #or die("Couldn't connect to server: $DB_POP3_host <br>\n");
     $headers = 0;
     $headers = @imap_headers($conn);
     # or die("Couldn't get email headers!");
     if ($headers) {
         $Num_Emails = sizeof($headers);
         for ($i = 1; $i <= $Num_Emails; $i++) {
             $mailHeader = imap_headerinfo($conn, $i);
             $mail_body = imap_fetchbody($conn, $i, 0);
             $subject = MakeSafe($mailHeader->subject);
             $date = MakeSafe($mailHeader->date);
             $mail_body = MakeSafe($mail_body);
             $from = $mailHeader->from;
             foreach ($from as $id => $object) {
                 $fromname = $object->personal;
                 $fromaddress = $object->mailbox . "@" . $object->host;
                 $fromhost = $object->host;
             }
Beispiel #28
0
 function getTotalMails()
 {
     $headers = imap_headers($this->mailResource);
     return count($headers);
 }
Beispiel #29
0
 function mailcount()
 {
     return count(imap_headers($this->mbox));
 }
Beispiel #30
0
 /**
  * @return array
  */
 public function getAllMailHeader()
 {
     return imap_headers($this->getImapStream());
 }