}
}
+ function decodeEmailAddr($sender) {
+ $emailAddr = getEmailAddr($sender);
+ $emailStart = strpos($emailAddr, "EMAILSTART--");
+ $emailEnd = strpos($emailAddr, "--EMAILEND") - 10;
+
+ $emailAddr = ereg_replace("EMAILSTART--", "", $emailAddr);
+ $emailAddr = ereg_replace("--EMAILEND", "", $emailAddr);
+ return $emailAddr;
+ }
+
function getEmailAddr($sender) {
if (strpos($sender, "EMAILSTART--") == false)
return "";
$wrap_at = 80; // Make this configurable int the config file some time
if (strlen($line) - 2 >= $wrap_at) // -2 because of the ^^ at the beginning
$line = wordWrap($line, $wrap_at);
+
$line = str_replace(" ", " ", $line);
$line = str_replace("\t", " ", $line);
"www" and "mailto" also. That should probably be added later. **/
if (strpos(strtolower($line), "http://") != false) {
$start = strpos(strtolower($line), "http://");
- $link = substr($line, $start, strlen($line));
+ $text = substr($line, $start, strlen($line));
+ $link = ereg_replace("<BR>", "", $text);
if (strpos($link, "&"))
$end = strpos($link, "&");
$end = strlen($link);
$link = substr($link, 0, $end);
-
- $line = str_replace($link, "<A HREF=\"$link\" TARGET=_top>$link</A>", $line);
+ $line = str_replace($text, "<A HREF=\"$link\" TARGET=_top>$text</A>", $line);
}
return $line;
}
+
+ function getMessageHeadersTo($imapConnection, $start, $end, &$to) {
+ $rel_start = $start;
+ if (($start > $end) || ($start < 1)) {
+ echo "Error in message header fetching. Start message: $start, End message: $end<BR>";
+ exit;
+ }
+
+ $pos = 0;
+ while ($rel_start <= $end) {
+ if ($end - $rel_start > 50) {
+ $rel_end = $rel_start + 49;
+ } else {
+ $rel_end = $end;
+ }
+ fputs($imapConnection, "messageFetch FETCH $rel_start:$rel_end RFC822.HEADER.LINES (To)\n");
+ $read = fgets($imapConnection, 1024);
+
+ while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
+ if (substr($read, 0, 3) == "To:") {
+ $read = ereg_replace("<", "<", $read);
+ $read = ereg_replace(">", ">", $read);
+ $to[$pos] = substr($read, 3, strlen($read));
+ if (strlen(Chop($to[$pos])) == 0)
+ $to[$pos] = "Unknown Recipients";
+ }
+ else if (substr($read, 0, 1) == ")") {
+ if ($subject[$pos] == "")
+ $subject[$pos] = "Unknown Recipients";
+ $pos++;
+ }
+
+ $read = fgets($imapConnection, 1024);
+ }
+ $rel_start = $rel_start + 50;
+ }
+ }
+
?>