function selectMailbox($imapConnection, $mailbox, &$numberOfMessages) {
// select mailbox
fputs($imapConnection, "mailboxSelect SELECT \"$mailbox\"\n");
- $read = fgets($imapConnection, 1024);
- $unseen = false;
- while ((substr($read, 0, 16) != "mailboxSelect OK") && (substr($read, 0, 17) != "mailboxSelect BAD")) {
- if (substr(Chop($read), -6) == "EXISTS") {
- $array = explode(" ", $read);
+ $data = imapReadData($imapConnection, "mailboxSelect");
+ for ($i = 0; $i < count($data); $i++) {
+ if (substr(Chop($data[$i]), -6) == "EXISTS") {
+ $array = explode(" ", $data[$i]);
$numberOfMessages = $array[1];
}
- $read = fgets($imapConnection, 1024);
}
}
fputs($imapConnection, "1 EXPUNGE\n");
}
- function getFolderNameMinusINBOX($mailbox) {
- if (substr($mailbox, 0, 6) == "INBOX.")
- $box = substr($mailbox, 6, strlen($mailbox));
+ function getFolderNameMinusINBOX($mailbox, $del) {
+ $inbox = "INBOX" . $del;
+ if (substr($mailbox, 0, strlen($inbox)) == $inbox)
+ $box = substr($mailbox, strlen($inbox), strlen($mailbox));
else
$box = $mailbox;
}
function fetchHeader($imapConnection, $id) {
- fputs($imapConnection, "messageFetch FETCH $id:$id RFC822.HEADER.LINES (From Subject Date To Cc Content-Type MIME-Version)\n");
+ fputs($imapConnection, "messageFetch FETCH $id:$id RFC822.HEADER\n");
$read = fgets($imapConnection, 1024);
/** defaults... if the don't get overwritten, it will display text **/
}
}
+
+ /** REPLY-TO **/
+ else if (substr($read, 0, 9) == "Reply-To:") {
+ $header["REPLYTO"] = trim(substr($read, 9, strlen($read)));
+ $read = fgets($imapConnection, 1024);
+ }
+
/** FROM **/
else if (substr($read, 0, 5) == "From:") {
$header["FROM"] = trim(substr($read, 5, strlen($read) - 6));
+ if ($header["REPLYTO"] == "")
+ $header["REPLYTO"] = $header["FROM"];
$read = fgets($imapConnection, 1024);
}
/** DATE **/