Version 0.5pre1 -- DEVELOPMENT
------------------------------
+- Removed a bunch of annoying "success" screens
+- Better IMAP session handling
- Redid the options section and split it into different parts
- Added "view all headers" option when reading a message
- In-Reply-To and References headers are inserted when replying to a message.
******************************************************************************/
function sqimap_get_message ($imap_stream, $id, $mailbox) {
$header = sqimap_get_message_header($imap_stream, $id, $mailbox);
- $msg = sqimap_get_message_body(&$header);
+ $msg = sqimap_get_message_body($imap_stream, &$header);
return $msg;
}
/******************************************************************************
** Returns the body of a message.
******************************************************************************/
- function sqimap_get_message_body (&$header) {
+ function sqimap_get_message_body ($imap_stream, &$header) {
$id = $header->id;
//fputs ($imap_stream, "a001 FETCH $id:$id BODY[TEXT]\r\n");
//$read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
$i++;
}
*/
- return decodeMime($body, &$header);
+ return decodeMime($imap_stream, $body, &$header);
}
$id = $header->id;
fputs ($imap_stream, "a001 FETCH $id BODYSTRUCTURE\r\n");
$read = fgets ($imap_stream, 10000);
+ $endline = fgets($imap_stream, 1024);
$read = strtolower($read);
if ($debug_mime) echo "<tt>$read</tt><br><br>";
/** This is the first function called. It decides if this is a multipart
message or if it should be handled as a single entity
**/
- function decodeMime ($body, $header) {
+ function decodeMime ($imap_stream, $body, $header) {
global $username, $key, $imapServerAddress, $imapPort;
- $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
- sqimap_mailbox_select($imap_stream, $header->mailbox);
- $struct = mime_structure ($imap_stream, $header);
- sqimap_logout($imap_stream);
- return $struct;
+ return mime_structure ($imap_stream, $header);
}
// This is here for debugging purposese. It will print out a list
everything needed, including HTML Tags, Attachments at the
bottom, etc.
**/
- function formatBody($message, $color, $wrap_at) {
+ function formatBody($imap_stream, $message, $color, $wrap_at) {
// this if statement checks for the entity to show as the
// primary message. To add more of them, just put them in the
// order that is their priority.
$id = $message->header->id;
$urlmailbox = urlencode($message->header->mailbox);
- $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
- sqimap_mailbox_select($imap_stream, $message->header->mailbox);
-
$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
if ($id) {
sqimap_mailbox_select($imapConnection, $mailbox);
$message = sqimap_get_message($imapConnection, $id, $mailbox);
+ $orig_header = $message->header;
if ($ent_num)
$message = getEntity($message, $ent_num);
$body = "";
}
- if ($forward_id)
- $tmp = _("-------- Original Message ---------\n");
if ($message->header->type1 == "html")
$body = strip_tags($body);
$body_ary = explode("\n", $body);
$body = "";
for ($i=0; $i < count($body_ary); $i++) {
- if ($i==0 && $forward_id)
- $tmp = _("-------- Original Message ---------\n") . $body_ary[$i];
- else
+ if ($i==0 && $forward_id) {
+ $tmp = _("-------- Original Message ---------\n");
+ $tmp .= _("Subject") . ": " . $orig_header->subject . "\n";
+ $tmp .= " " . _("From") . ": " . $orig_header->from . "\n";
+ $tmp .= " " . _("To") . ": " . $orig_header->to[0] . "\n";
+ if (count($orig_header->to) > 1) {
+ for ($x=1; $x < count($orig_header->to); $x++) {
+ $tmp .= " " . $orig_header->to[$x] . "\n";
+ }
+ }
+ $tmp .= "\n" . $body_ary[$i];
+ } else {
$tmp = $body_ary[$i];
-
+ }
if ($forward_id)
- $body .= "$body$tmp\n";
+ $body = "$body$tmp\n";
else
- $body .= "$body> $tmp\n";
+ $body = "$body> $tmp\n";
}
return $body;
}
echo " </TD></TR>";
echo " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n";
- $body = formatBody($message, $color, $wrap_at);
+ $body = formatBody($imapConnection, $message, $color, $wrap_at);
echo "<BR>";
echo "$body";