var $type0, $type1, $boundary, $charset, $encoding;
var $to, $from, $date, $cc, $bcc, $reply_to, $subject;
var $id, $mailbox, $description;
- var $entity_id;
+ var $entity_id, $message_id;
}
class message {
global $username, $key, $imapServerAddress, $imapPort;
$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
sqimap_mailbox_select($imap_stream, $header->mailbox);
-
- return mime_structure ($imap_stream, $header);
+ $struct = mime_structure ($imap_stream, $header);
+ sqimap_logout($imap_stream);
+ return $struct;
}
// This is here for debugging purposese. It will print out a list
$ent_num = findDisplayEntity ($message);
$body = mime_fetch_body ($imap_stream, $id, $ent_num);
+ sqimap_logout($imap_stream);
// If there are other types that shouldn't be formatted, add
// them here
$body = translateText($body, $wrap_at, $charset);
}
- $body .= "<BR><SMALL><CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$ent_num&mailbox=$urlmailbox\">". _("Download this as a file") ."</A></CENTER><BR></SMALL>";
+ $body .= "<SMALL><CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$ent_num&mailbox=$urlmailbox\">". _("Download this as a file") ."</A></CENTER><BR></SMALL>";
/** Display the ATTACHMENTS: message if there's more than one part **/
if ($message->entities) {
$body .= "<TT> <A HREF=\"../src/download.php?passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent\">" . $display_filename . "</A> (TYPE: $type0/$type1)";
if ($message->header->description)
$body .= " <b>" . htmlspecialchars($message->header->description)."</b>";
+ if ($message->header->type0 == "image" &&
+ ($message->header->type1 == "jpg" ||
+ $message->header->type1 == "jpeg" ||
+ $message->header->type1 == "gif" ||
+ $message->header->type1 == "png"))
+ $body .= " (<a href=\"../src/download.php?passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent&view=true\">"._("view")."</a>)\n";
$body .= "</TT><BR>";
$num++;
}
}
// Encode a string according to RFC 1522 for use in headers if it
- // contains 8-bit characters
+ // contains 8-bit characters or anything that looks like it should
+ // be encoded.
function encodeHeader ($string) {
global $default_charset;
- // Encode only if the string contains 8-bit characters
- if (ereg("[\200-\377]", $string)) {
+ // Encode only if the string contains 8-bit characters or =?
+ if (ereg("([\200-\377])|=\\?", $string)) {
$newstring = "=?$default_charset?Q?";
- $newstring .= str_replace(" ", "_", $string);
- while (ereg("([\200-\377])", $newstring, $regs)) {
+ // First the special characters
+ $string = str_replace("=", "=3D", $string);
+ $string = str_replace("?", "=3F", $string);
+ $string = str_replace("_", "=5F", $string);
+ $string = str_replace(" ", "_", $string);
+
+
+ while (ereg("([\200-\377])", $string, $regs)) {
$replace = $regs[1];
- $insert = "=" . bin2hex($replace);
- $newstring = str_replace($replace, $insert, $newstring);
+ $insert = "=" . strtoupper(bin2hex($replace));
+ $string = str_replace($replace, $insert, $string);
}
- $newstring .= "?=";
-
+ $newstring = "=?$default_charset?Q?".$string."?=";
+
return $newstring;
}