#543 Inline Message Preview

open
nobody
5
2008-08-19
2008-08-19
mike tosh
No

I would just LOVE to have an inline message preview, just like Outlook's text-part preview. This helps me safely determine which new messages are spam, and if I should even bother opening the message to read it.

Here is some code I wrote that appears to be a half-attempt to get it done:

$ diff -u0 mailbox_display.php.old mailbox_display.php
--- mailbox_display.php.old Tue Aug 19 13:25:47 2008
+++ mailbox_display.php Tue Aug 19 13:13:21 2008
@@ -307,0 +308,4 @@
+ if (!isset($msg['FLAG_SEEN']) || ($msg['FLAG_SEEN'] == false)) {
+ // HERE MORE STUFF
+ echo '</tr><tr><td colspan=20><small><small>' . (isset($msg['PREVIEW']) ? $msg['PREVIEW'] : '') . '<br><br></td>'."\n";
+ }
@@ -311,0 +316,4 @@
+ if (!isset($msg['FLAG_SEEN']) || ($msg['FLAG_SEEN'] == false)) {
+ // HERE MORE STUFF
+ echo '<tr><td colspan=20><small><small>' . (isset($msg['PREVIEW']) ? $msg['PREVIEW'] : '') . '<br><br></td></tr>'."\n";
+ }
oreomike@webbox:/var/www/ssldocs/mail/functions
$ diff -u0 imap_messages.php.old imap_messages.php
--- imap_messages.php.old Tue Aug 19 13:27:11 2008
+++ imap_messages.php Tue Aug 19 13:10:31 2008
@@ -532,0 +533,2 @@
+ $textpart="1";
+
@@ -535 +537 @@
- $query = "FETCH $msgs_str (FLAGS UID RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (Date To Cc From Subject X-Priority Importance Priority Content-Type)])";
+ $query = "FETCH $msgs_str (FLAGS UID RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (Date To Cc From Subject X-Priority Importance Priority Content-Type)] BODY.PEEK[$textpart]<0.200>)";
@@ -537 +539 @@
- $query = "FETCH $msgs_str (FLAGS UID RFC822.SIZE BODY.PEEK[HEADER.FIELDS (Date To Cc From Subject X-Priority Importance Priority Content-Type)])";
+ $query = "FETCH $msgs_str (FLAGS UID RFC822.SIZE BODY.PEEK[HEADER.FIELDS (Date To Cc From Subject X-Priority Importance Priority Content-Type)] BODY.PEEK[$textpart]<0.200>)";
@@ -636,0 +639,5 @@
+ case "BODY[$textpart]<0>":
+ $i = strpos($read,'{',$i);
+ $tmp = parseString($read,$i);
+ $previewtext = strip_tags(trim(str_replace(array("\r\n", "\t", "\n"),array(' ', ' ', ' '), $tmp)));
+ break;
@@ -723,0 +731 @@
+ $messages[$msgi]['PREVIEW'] = $previewtext;

Discussion

  • An interesting idea, however I think the implementation might be a little flawed. It makes the assumption that the text part is always part 1. In a multi-part related message, that cannot always be assumed. Part 1 in a multi-part related message is, in fact, another MIME structure, which would require the fetching of the sub headers to parse, and finding out where the text is, so you can then do 1.x where x is the new text portion. This could introduce some extra load on both web server (for parsing the full headers via a BODYSTRUCTURE call), and the IMAP server for having to retrieve more information.