From f7fb20fe344ee5e3567937d2530032778802e9ed Mon Sep 17 00:00:00 2001 From: lkehresman Date: Mon, 13 Dec 1999 13:53:52 +0000 Subject: [PATCH] Added BASIC mime support. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@75 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/compose.php | 2 ++ src/read_body.php | 52 ++++++++++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/compose.php b/src/compose.php index 1be7a42d..38ca4215 100644 --- a/src/compose.php +++ b/src/compose.php @@ -5,6 +5,8 @@ include("../functions/imap.php"); include("../functions/mailbox.php"); include("../functions/date.php"); + include("../functions/mime.php"); + echo "\n"; $imapConnection = loginToImapServer($username, $key, $imapServerAddress); diff --git a/src/read_body.php b/src/read_body.php index 8a8f0c00..4c751686 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -3,6 +3,7 @@ include("../functions/strings.php"); include("../functions/page_header.php"); include("../functions/imap.php"); + include("../functions/mime.php"); include("../functions/mailbox.php"); include("../functions/date.php"); @@ -11,29 +12,24 @@ echo "\n"; displayPageHeader($mailbox); - $body = fetchBody($imapConnection, $passed_id); - getMessageHeaders($imapConnection, $passed_id, $passed_id, $f, $s, $d); - getMessageHeadersTo($imapConnection, $passed_id, $t); - getMessageHeadersCc($imapConnection, $passed_id, $c); - $subject = $s[0]; - $url_subj = urlencode(trim($subject)); + // $message contains all information about the message + // including header and body + $message = fetchMessage($imapConnection, $passed_id); - $d[0] = ereg_replace(" ", " ", $d[0]); - $dateParts = explode(" ", trim($d[0])); - $dateString = getLongDateString($dateParts); - - $from_name = getSenderName($f[0]); + /** 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_from = trim(decodeEmailAddr($f[0])); - $url_from = urlencode($url_from); + $dateString = getLongDateString($message["HEADER"]["DATE"]); /** FORMAT THE TO STRING **/ $i = 0; $to_string = ""; - $to_ary = $t; + $to_ary = $message["HEADER"]["TO"]; while ($i < count($to_ary)) { + $to_ary[$i] = htmlspecialchars($to_ary[$i]); if ($to_string) $to_string = "$to_string
$to_ary[$i]"; else @@ -55,8 +51,9 @@ /** FORMAT THE CC STRING **/ $i = 0; $cc_string = ""; - $cc_ary = $c; + $cc_ary = $message["HEADER"]["CC"]; while ($i < count($cc_ary)) { + $cc_ary[$i] = htmlspecialchars($cc_ary[$i]); if ($cc_string) $cc_string = "$cc_string
$cc_ary[$i]"; else @@ -75,7 +72,9 @@ } } - + /** make sure everything will display in HTML format **/ + $from_name = htmlspecialchars($message["HEADER"]["FROM"]); + $subject = htmlspecialchars($message["HEADER"]["SUBJECT"]); echo "
"; echo "\n"; @@ -131,7 +130,7 @@ echo " \n"; echo " \n"; /** cc **/ - if ($c[0]) { + if ($message["HEADER"]["CC"][0]) { echo " \n"; echo "
\n"; echo " Cc:\n"; @@ -143,10 +142,21 @@ echo "
\n"; echo "
\n"; - $i = 0; - while ($i < count($body)) { - echo "$body[$i]"; - $i++; + if (count($message["ENTITIES"]) > 1) { + echo "This is a multipart MIME encoded message.
"; + $i = 0; + while ($i < count($message["ENTITIES"])) { + echo "--(PART $i)--
"; + for ($p = 0; $p < count($message["ENTITIES"][$i][0]["BODY"]); $p++) { + echo $message["ENTITIES"][$i][0]["BODY"][$p]; + } + $i++; + } + } else { + echo "This is a single part mime encoded message
"; + for ($p = 0; $p < count($message["ENTITIES"][0]["BODY"]); $p++) { + echo $message["ENTITIES"][0]["BODY"][$p]; + } } echo "
\n"; echo "  "; -- 2.25.1