added "reply-to" capabilities
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 14 Dec 1999 20:28:35 +0000 (20:28 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 14 Dec 1999 20:28:35 +0000 (20:28 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@79 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/mailbox.php
functions/mime.php
src/compose.php
src/read_body.php

index 8f9c92a..383da2d 100644 (file)
    }
 
    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 **/
index aabd9cd..6182250 100644 (file)
@@ -6,7 +6,7 @@
 
 
    function decodeMime($body, $bound, $type0, $type1) {
-      echo "$type0/$type1<BR>";
+//      echo "$type0/$type1<BR>";
       if ($type0 == "multipart") {
          if ($body[0] == "")
             $i = 1;
@@ -42,7 +42,7 @@
 
    /** This gets one entity's properties **/
    function getEntity($body, $bound, $type0, $type1, $encoding, $charset) {
-      echo "$type0/$type1<BR>";
+//      echo "$type0/$type1<BR>";
       $msg[0]["TYPE0"] = $type0;
       $msg[0]["TYPE1"] = $type1;
       $msg[0]["ENCODING"] = $encoding;
index 38ca421..83cb45b 100644 (file)
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
    displayPageHeader("None");
 
-   if ($reply_id) {
+   if ($reply_id || $forward_id) {
       selectMailbox($imapConnection, $mailbox, $numMessages);
-      $body_ary = fetchBody($imapConnection, $reply_id);
-      for ($i=0;$i < count($body_ary);$i++) {
-         $tmp = strip_tags($body_ary[$i]);
-         $tmp = substr($tmp, 0, strlen($tmp) -1);
-         $body = "$body> $tmp";
-      }
-   } else if ($forward_id) {
-      selectMailbox($imapConnection, $mailbox, $numMessages);
-      $body_ary = fetchBody($imapConnection, $forward_id);
+      if ($reply_id)
+         $msg = fetchMessage($imapConnection, $reply_id);
+      else
+         $msg = fetchMessage($imapConnection, $forward_id);
+
+      $body_ary = formatBody($msg);
       for ($i=0;$i < count($body_ary);$i++) {
          $tmp = strip_tags($body_ary[$i]);
          $tmp = substr($tmp, 0, strlen($tmp) -1);
    }
 
    echo "<FORM action=\"compose_send.php\" METHOD=POST>\n";
-   echo "<TABLE COLS=2 WIDTH=100% ALIGN=CENTER CELLSPACING=0>\n";
+   echo "<TABLE COLS=2 WIDTH=50 ALIGN=CENTER CELLSPACING=0 BORDER=0>\n";
    echo "   <TR>\n";
-   echo "      <TD WIDTH=15% BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
+   echo "      <TD WIDTH=50 BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
    echo "         <FONT FACE=\"Arial,Helvetica\">To: </FONT>\n";
-   echo "      </TD><TD WIDTH=85% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
+   echo "      </TD><TD WIDTH=% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
    if ($send_to)
       echo "         <INPUT TYPE=TEXT NAME=passed_to VALUE=\"$send_to\" SIZE=60><BR>";
    else
    echo "      </TD>\n";
    echo "   </TR>\n";
    echo "   <TR>\n";
-   echo "      <TD WIDTH=15% BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
+   echo "      <TD WIDTH=50 BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
    echo "         <FONT FACE=\"Arial,Helvetica\">CC:</FONT>\n";
-   echo "      </TD><TD WIDTH=85% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
+   echo "      </TD><TD WIDTH=% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
    echo "         <INPUT TYPE=TEXT NAME=passed_cc SIZE=60><BR>";
    echo "      </TD>\n";
    echo "   </TR>\n";
    echo "   <TR>\n";
-   echo "      <TD WIDTH=15% BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
+   echo "      <TD WIDTH=50 BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
    echo "         <FONT FACE=\"Arial,Helvetica\">BCC:</FONT>\n";
-   echo "      </TD><TD WIDTH=85% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
+   echo "      </TD><TD WIDTH=% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
    echo "         <INPUT TYPE=TEXT NAME=passed_bcc SIZE=60><BR>";
    echo "      </TD>\n";
    echo "   </TR>\n";
 
    echo "   <TR>\n";
-   echo "      <TD WIDTH=15% BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
+   echo "      <TD WIDTH=50 BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
    echo "         <FONT FACE=\"Arial,Helvetica\">Subject:</FONT>\n";
-   echo "      </TD><TD WIDTH=85% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
+   echo "      </TD><TD WIDTH=% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
    if ($reply_subj) {
       $reply_subj = str_replace("\"", "'", $reply_subj);
       $reply_subj = stripslashes($reply_subj);
-      echo "         <INPUT TYPE=TEXT NAME=passed_subject SIZE=60 VALUE=\"Re: $reply_subj\"><BR>";
+      $reply_subj = trim($reply_subj);
+      if (substr(strtolower($reply_subj), 0, 3) != "re:")
+         $reply_subj = "Re: $reply_subj";
+      echo "         <INPUT TYPE=TEXT NAME=passed_subject SIZE=60 VALUE=\"$reply_subj\">";
    } else if ($forward_subj) {
-      $forward_subj = stripquotes($forward_subj);
-      echo "         <INPUT TYPE=TEXT NAME=passed_subject SIZE=60 VALUE=\"[Fwd: $forward_subj]\"><BR>";
+      $forward_subj = str_replace("\"", "'", $forward_subj);
+      $forward_subj = stripslashes($forward_subj);
+      $forward_subj = trim($forward_subj);
+      if ((substr(strtolower($forward_subj), 0, 4) != "fwd:") &&
+          (substr(strtolower($forward_subj), 0, 5) != "[fwd:") &&
+          (substr(strtolower($forward_subj), 0, 6) != "[ fwd:"))
+         $forward_subj = "[Fwd: $forward_subj]";
+      echo "         <INPUT TYPE=TEXT NAME=passed_subject SIZE=60 VALUE=\"$forward_subj\">";
    } else {
       echo "         <INPUT TYPE=TEXT NAME=passed_subject SIZE=60>";
    }
    echo "      </TD>\n";
    echo "   </TR>\n";
    echo "   <TR>\n";
-   echo "      <TD BGCOLOR=FFFFFF ALIGN=RIGHT VALIGN=TOP>\n";
-   echo "      </TD>";
-   echo "      <TD BGCOLOR=FFFFFF>\n";
-   echo "         <TEXTAREA NAME=passed_body ROWS=20 COLS=76 WRAP=HARD>$body</TEXTAREA><BR>";
+   echo "      <TD BGCOLOR=FFFFFF COLSPAN=2>\n";
+   echo "         &nbsp;&nbsp;<TEXTAREA NAME=passed_body ROWS=20 COLS=76 WRAP=HARD>$body</TEXTAREA><BR>";
    echo "      </TD>";
    echo "   </TR>\n";
    echo "</TABLE>\n";
index 7e98d1a..88c1093 100644 (file)
@@ -22,7 +22,7 @@
    /** translate the subject and mailbox into url-able text **/
    $url_subj = urlencode(trim($message["HEADER"]["SUBJECT"]));
    $urlMailbox = urlencode($mailbox);
-   $url_from = urlencode($message["HEADER"]["FROM"]);
+   $url_replyto = urlencode($message["HEADER"]["REPLYTO"]);
 
    $dateString = getLongDateString($message["HEADER"]["DATE"]);
 
@@ -91,7 +91,7 @@
    echo "            </TD><TD WIDTH=50% ALIGN=RIGHT>";
    echo "               <FONT FACE=\"Arial,Helvetica\" SIZE=2>";
    echo "               <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox\">Forward</A>&nbsp;&nbsp;";
-   echo "               <A HREF=\"compose.php?send_to=$url_from&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">Reply</A>&nbsp;&nbsp;";
+   echo "               <A HREF=\"compose.php?send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">Reply</A>&nbsp;&nbsp;";
    echo "               </FONT>";
    echo "            </TD>";
    echo "         </TR>";
 
    echo "   <TR><TD BGCOLOR=FFFFFF WIDTH=100%>\n";
    $body = formatBody($message);
+
    for ($i = 0; $i < count($body); $i++) {
       echo "$body[$i]";
    }
 
-/*   if (count($message["ENTITIES"]) > 1) {
-      echo "</TD></TR><TR><TD BGCOLOR=DCDCDC><CENTER><B><FONT COLOR=DD0000>This is a multipart MIME encoded message.</FONT></B></CENTER></TD></TR><TR><TD BGCOLOR=FFFFFF WIDTH=100%>";
-      echo "";
-
-      $i = 0;
-      $q = 0;
-      $entity[0] = $i;
-      while ($i < count($message["ENTITIES"])) {
-         $b = $i + 1;
-         echo "</TD></TR><TR><TD BGCOLOR=DCDCDC><CENTER>Part $b</CENTER></TD></TR><TR><TD BGCOLOR=FFFFFF WIDTH=100%>";
-         for ($p = 0; $p < count($message["ENTITIES"][$i][0]["BODY"]); $p++) {
-            echo $message["ENTITIES"][$i][0]["BODY"][$p];
-         }
-         $i++;
-      }
-   } else {
-      echo "</TD></TR><TR><TD BGCOLOR=DCDCDC><CENTER><B><FONT COLOR=DD0000>This is a single part MIME encoded message.</FONT></B></CENTER></TD></TR><TR><TD BGCOLOR=FFFFFF WIDTH=100%>";
-      for ($p = 0; $p < count($message["ENTITIES"][0]["BODY"]); $p++) {
-         echo $message["ENTITIES"][0]["BODY"][$p];
-      }
-   }
-*/
    echo "   <BR></TD></TR>\n";
    echo "   <TR><TD BGCOLOR=DCDCDC>&nbsp;</TD></TR>";
    echo "</TABLE>\n";