diff -ruN ../aero_221_srcfix/changes ./changes
--- ../aero_221_srcfix/changes	2004-08-09 09:32:56.000000000 -0400
+++ ./changes	2004-09-09 20:15:37.000000000 -0400
@@ -114,3 +114,25 @@
 * Fixed some invalid HTML
 * Fixed sendmail options: a single dot on a line trucated qprint encoded
   messages
+
+Version 2.22lmb - Laird Bedore
+
+* Added support and configuration for SSL-encrypted IMAP servers
+* Fixed FORCE_FROM to work with qmail (added SERVER_SUFFIX explicit domain)
+* Fixed an infinite loop generated by some inline images
+* Fixed email links that contained a ">" at the end of them
+* Fixed some W3C-compatibility issues with font sizes
+* Fixed missing body style information (browser consistency improved)
+* Changed background color of table.main (the lines inbetween table cells)
+* Adjusted the layout to adjust to the size of the data first, then
+  adjust to the size of the screen afterwards
+* Tightened display padding in tables to fit better in small browser windows
+* Improved the bold-display of new messages
+* Shrunk date and size fields, forced them to display on a single line
+* Removed the display of the "To:" field in normal folders- it makes for
+  a real display nightmare when you receive mailing-list messages
+* Added option to force word-wrap when displaying plain text
+* Added option to display shorter email address field for addresses that
+  have the "personal name" defined
+* Added option to get rid of duplicate INBOX folder for some IMAP server
+  configurations
diff -ruN ../aero_221_srcfix/config.inc ./config.inc
--- ../aero_221_srcfix/config.inc	2004-09-04 19:03:17.000000000 -0400
+++ ./config.inc	2004-09-09 20:03:06.000000000 -0400
@@ -34,9 +34,15 @@
 // server type should either be "Cyrus" or "UWash"
 define('IMAP_SERVER_TYPE', "UWash");
 
-// tcp port where the IMAP server is running - default is 143
+// tcp port where the IMAP server is running - default is 143, SSL is 993
 define('IMAP_PORT', "143");
 
+// IMAP options may be necessary when connecting to an SSL-enabled server
+define('IMAP_OPTS', "");
+//define('IMAP_OPTS', "/imap");
+//define('IMAP_OPTS', "/imap/ssl");
+//define('IMAP_OPTS', "/imap/ssl/novalidate-cert");
+
 // url to redirect to when a user clicks on cancel when loggin in
 define('SERVER_REDIR', "http://aeromail.nicolaas.net/");
 
@@ -47,6 +53,20 @@
 // AeroMail let sendmail and genericstable figure it out (0=no 1=yes)
 define('FORCE_FROM', 1);
 
+// If you are using the force_from, define a server suffix.
+define('SERVER_SUFFIX',"mydomain.com");
+
+// should AeroMail force word-wrap when displaying plaintext messages?
+// 0 to disable. Default is 81 characters.
+define('WRAP_AT_COLUMN',81);
+
+// When displaying a folder list, should we display both the "personal"
+// name and the email address when available, or just the personal name?
+define('DISPLAY_FULL_ADDR',0);
+
+// If you see two INBOX's in your folder list, change the line below to 1.
+define('NO_INBOX_EXPLICIT',0);
+
 //-----------------------
 // extra features
 //-----------------------
diff -ruN ../aero_221_srcfix/folder.php ./folder.php
--- ../aero_221_srcfix/folder.php	2004-09-09 20:16:56.000000000 -0400
+++ ./folder.php	2004-09-09 20:04:11.000000000 -0400
@@ -54,7 +54,7 @@
         sort($mailboxes);
         $first = "rowoff";
         $second = "rowon";
-        if (FILTER != "INBOX")
+        if (FILTER != "INBOX" && NO_INBOX_EXPLICIT != 1)
         {
             body_row('class="rowon"');
             body_left();
diff -ruN ../aero_221_srcfix/global.inc ./global.inc
--- ../aero_221_srcfix/global.inc	2004-09-04 19:03:27.000000000 -0400
+++ ./global.inc	2004-09-09 20:06:54.000000000 -0400
@@ -1,12 +1,12 @@
 <?php
 
 // shouldn't have to modify anything in this file...
-define('VERSION', "AeroMail 2.21");
+define('VERSION', "AeroMail 2.22");
 
 include("config.inc");
 
 define('FILTER', IMAP_SERVER_TYPE == "Cyrus" ? "INBOX" : PROG_DIR);
-define('IMAP_STR', "{".IMAP_SERVER.":".IMAP_PORT."}");
+define('IMAP_STR', "{".IMAP_SERVER.":".IMAP_PORT.IMAP_OPTS."}");
 
 function mailbox_log_in( $folder )
 {
@@ -96,11 +96,14 @@
     $l = array();
     foreach ($list as $adr)
     {
+	if (DISPLAY_FULL_ADDR)
+	  $linkdisplay = htmlspecialchars(decode_header_string($adr));
+	else
+	  $linkdisplay = strip_tags(str_replace("\"","",$adr));
         $l[] = "<a href=\"compose.php?folder="
             . urlencode($folder) 
             . "&amp;to=" . urlencode($adr) . "\">"
-            .  htmlspecialchars(decode_header_string($adr))
-            . "</a>";
+            .  $linkdisplay . "</a>";
     }
     return implode(", ", $l);
 }
@@ -112,7 +115,7 @@
     {
         sort($mailboxes);
         $num_boxes = count($mailboxes);
-        if (FILTER != "INBOX") { echo "<option>INBOX"; }
+        if (FILTER != "INBOX" && NO_INBOX_EXPLICIT != 1) { echo "<option>INBOX"; }
         for ($index = 0; $index < $num_boxes; $index++)
         {
             $nm = substr($mailboxes[$index], strrpos($mailboxes[$index], "}") + 1, strlen($mailboxes[$index]));
@@ -386,8 +389,11 @@
         $dsp = make_utf8($dsp, $charset);
         if (strtolower($type) == "text/plain")
         {
-            /* For text/plain we assume the user took care of line breaks;
+            /* For text/plain we exhibit the line break behavior defined
+               in the config.inc 
              */
+            if (WRAP_AT_COLUMN)
+              $dsp = forcelinebreaks($dsp,WRAP_AT_COLUMN);
             $dsp = htmlspecialchars($dsp);
             $dsp = make_clickable($dsp);
             echo "<pre>$dsp</pre>";
@@ -402,7 +408,10 @@
             $struct = imap_fetchstructure($mailbox, $msgnum);
             while (ereg("cid:([^\"]*)", $dsp, $regs))
             {
-                $dsp = ereg_replace("cid:" . $regs[1], cid_name($struct, $regs[1]), $dsp);
+                /* WARNING: MAKE SURE you quotemeta() on $regs[1]. They can
+		    (and often do) contain $ characters.
+                */
+                $dsp = ereg_replace("cid:" . quotemeta($regs[1]), cid_name($struct, $regs[1]), $dsp);
             }
             $dsp = make_safe_html($dsp);
             echo $dsp;
@@ -563,7 +572,7 @@
     global $folder;
     $ret = eregi_replace( "([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])",
         "<a href=\"\\1://\\2\\3\" target=\"_new\">\\1://\\2\\3</a>", $text);
-    $ret = eregi_replace( "(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))",
+    $ret = eregi_replace( "(([a-z0-9_]|\\-|\\.)+@([^[:space:]&^>&^<]*)([[:alnum:]-]))",
         "<a href=\"compose.php?folder=" . urlencode($folder) . "&amp;to=\\1\">\\1</a>", $ret);
     return($ret);
 }
@@ -591,6 +600,47 @@
     return htmlspecialchars($url);
 }
 
+function forcelinebreaks($dsp,$charcount) {
+  /*  lastLB = last-known line break (absolute position)
+      nextSP = next-known space, if any (relative to lastLB)
+      nextLB = next-known line break, if any (relative to lastLB)
+      walkback = the last space prior to the $charcount position
+  */
+    $lastLB = 0;
+    $dsptemp = "";
+    for ($n = 0; $n < strlen($dsp); $n++) {
+        if (strcmp(substr($dsp,$n,1), "\n") == 0)
+          $lastLB = $n;
+        $nextSP = strpos(substr($dsp,$lastLB)," ");
+        $nextLB = strpos(substr($dsp,$lastLB),"\n");
+        if (($nextSP > $charcount) && ($nextLB > $charcount)) {
+            // Jmp ahead to the next space or newline.
+            if ($nextSP > $nextLB) {
+                # closest is newline. go there.
+                $dsptemp .= substr($dsp,$n,$nextLB + 1);
+                $lastLB = $nextLB + $n;
+                $n = $lastLB + 1;
+            } else {
+                # closest is space. go there.
+                $dsptemp .= substr($dsp,$n,$nextSP) . "\n";
+                $lastLB = $nextSP + $n;
+                $n = $lastLB;
+            } // end if nextSP > nextLB
+        } else if ($nextSP < 1) {
+            // do nothing (don't walk back!). just keep walking the string.
+        } else if ($n - $lastLB > $charcount) {
+            // walk backwards on the string to the last space
+            $walkback = strrpos(substr($dsp,$lastLB,$charcount)," ");
+            $curpos = $lastLB + $walkback;
+            $dsptemp = substr($dsptemp,0,$curpos) . "\n";
+            $lastLB = $curpos + 1;
+            $n = $lastLB;
+        } // end if nextSP > charcount          
+        $dsptemp .= substr($dsp,$n,1);
+    } // end for n < strlen($dsp)
+    return $dsptemp;
+} // End function forcelinebreaks
+
 function login_prompt()
 {
     Header("WWW-Authenticate: Basic realm=\"" . PROG_NAME . "\"");
diff -ruN ../aero_221_srcfix/index.php ./index.php
--- ../aero_221_srcfix/index.php	2004-09-04 19:03:32.000000000 -0400
+++ ./index.php	2004-09-04 18:48:12.000000000 -0400
@@ -234,22 +234,23 @@
         if ($sort == 100 + SORTFROM)
             echo "<img src=\"images/descending.gif\" alt=\"v\" width=\"8\" height=\"8\" border=\"0\">";
         title_left_end();
-    }
-    title_left();
-    echo "<a href=\"";
-    if ($sort == SORTTO)
-        $s = 100 + SORTTO;
-    else
-        $s = SORTTO;
-    echo self_with_param("sort", $s);
-    echo "\">";
-    echo L_TO_HDR;
-    echo "&nbsp;";
-    if ($sort == SORTTO)
-        echo "<img src=\"images/ascending.gif\" alt=\"^\" width=\"8\" height=\"8\" border=\"0\">";
-    if ($sort == 100 + SORTTO)
-        echo "<img src=\"images/descending.gif\" alt=\"v\" width=\"8\" height=\"8\" border=\"0\">";
-    title_left_end();
+    } else {
+        title_left();
+        echo "<a href=\"";
+        if ($sort == SORTTO)
+            $s = 100 + SORTTO;
+        else
+            $s = SORTTO;
+        echo self_with_param("sort", $s);
+        echo "\">";
+        echo L_TO_HDR;
+        echo "&nbsp;";
+        if ($sort == SORTTO)
+            echo "<img src=\"images/ascending.gif\" alt=\"^\" width=\"8\" height=\"8\" border=\"0\">";
+        if ($sort == 100 + SORTTO)
+            echo "<img src=\"images/descending.gif\" alt=\"v\" width=\"8\" height=\"8\" border=\"0\">";
+        title_left_end();
+    } // end else on if !issentmail for heading
     title_left();
     echo "<a href=\"";
     if ($issentmail)
@@ -400,29 +401,33 @@
         echo "</a>$attach\n";
         if ($possible_spam)
             print "<br><font color=\"red\"><small>($ret)</small></font>";
-        if ($msg->Unseen)
+        if ($msg->Unseen == 'U' || $msg->Recent == 'N')
             print "</b>";
         body_left_end();
         if(!$issentmail)
         {
             body_left();
-            if($msg->from)
+            if($msg->from) {
+                if ($msg->Unseen == 'U' || $msg->Recent == 'N')
+                  print "<b>";
                 echo make_clickable_list($msg->from, $folder);
-            else
+            } else
                 echo L_NO_FROM;
             body_left_end();
+        } else {
+            // Hide To: field unless displaying the sent items folder.
+            body_left();
+            if ($msg->to)
+                echo make_clickable_list($msg->to, $folder);
+            else
+                echo L_NO_TO;
+            body_left_end();
         }
-        body_left();
-        if ($msg->to)
-            echo make_clickable_list($msg->to, $folder);
-        else
-            echo L_NO_TO;
+        body_left('class="row-small"');
+        echo "<nobr>".date(L_DATE_FORMAT, $msg->udate)."</nobr>";
         body_left_end();
-        body_left();
-        echo date(L_DATE_FORMAT, $msg->udate);
-        body_left_end();
-        body_left();
-        echo "$size\n";
+        body_left('class="row-small"');
+        echo "<nobr>$size</nobr>\n";
         body_left_end();
         body_row_end();
     }
diff -ruN ../aero_221_srcfix/layout.inc ./layout.inc
--- ../aero_221_srcfix/layout.inc	2004-09-04 19:04:07.000000000 -0400
+++ ./layout.inc	2004-09-04 15:18:27.000000000 -0400
@@ -3,7 +3,7 @@
 function content_start()
 {
 ?>
-<table class="main" cellpadding="0" cellspacing="0" width="100%">
+<table class="main" cellpadding="0" cellspacing="0">
 <?php
 //<tr><td>
 }
@@ -12,7 +12,7 @@
 {
 ?>
   <tr><td class="header">
-    <table border="0" cellpadding="5" cellspacing="1" width="100%">
+    <table border="0" cellpadding="3" cellspacing="1" width="100%">
       <tr>
 <?php
 }
@@ -92,7 +92,7 @@
 {
 ?>
   <tr><td>
-    <table border="0" cellpadding="5" cellspacing="1" width="100%">
+    <table border="0" cellpadding="3" cellspacing="1" width="100%">
 <?php
 }
 
diff -ruN ../aero_221_srcfix/send_message.php ./send_message.php
--- ../aero_221_srcfix/send_message.php	2004-09-04 19:05:00.000000000 -0400
+++ ./send_message.php	2004-09-04 18:53:02.000000000 -0400
@@ -22,12 +22,15 @@
        in bas64 except in the end.
     */
     $boundary = "=_Message-Boundary_=";
+    $mailheaders = "";
 
-    //$mailheaders  = "From: $user$SERVER_SUFFIX\r\n";
-    //$mailheaders .= "Reply-To: $user$SERVER_SUFFIX\r\n";
+    if (FORCE_FROM) {
+        $mailheaders .= "From: $user@".SERVER_SUFFIX."\r\n";
+        //$mailheaders .= "Reply-To: $user@".SERVER_SUFFIX."\r\n";
+    }
 
     $to = stripslashes($to);
-    $mailheaders = "To: ".removecrlf($to)."\n";
+    $mailheaders .= "To: ".removecrlf($to)."\n";
     $cc = stripslashes($cc);
     $mailheaders .= "Cc: ".removecrlf($cc)."\n";
 
@@ -72,7 +75,7 @@
 
     $mailheaders .= "Subject: " . removecrlf(stripslashes($subject)) . "\r\n\r\n";
 
-    $from_user = FORCE_FROM ? "$user@" . IMAP_SERVER : $user;
+    $from_user = FORCE_FROM ? "$user@" . SERVER_SUFFIX : $user;
 
     mailfrom($from_user, $msg_body, $mailheaders);
 
@@ -91,7 +94,10 @@
             $mailbox = mailbox_log_in(SENT_MAIL);
         }
 
-        $waxer = imap_append($mailbox, IMAP_STR. "$snt_folder", "From: $user@" . IMAP_SERVER . "\r\n" . $mailheaders . $msg_body);
+        if (FORCE_FROM)
+            $waxer = imap_append($mailbox, IMAP_STR. "$snt_folder", "From: $user@" . SERVER_SUFFIX . "\r\n" . $mailheaders . $msg_body);
+        else
+            $waxer = imap_append($mailbox, IMAP_STR. "$snt_folder", "From: $user@" . IMAP_SERVER . "\r\n" . $mailheaders . $msg_body);
     }
 
     if ($msgnum != "")
diff -ruN ../aero_221_srcfix/style.php ./style.php
--- ../aero_221_srcfix/style.php	2004-09-04 19:05:02.000000000 -0400
+++ ./style.php	2004-09-04 15:23:14.000000000 -0400
@@ -1,4 +1,5 @@
 <style type="text/css">
+    body {margin-top: 11; background-color: <?php echo COLOR_BG ?>; color: <?php echo COLOR_FONT ?> }
     a {color: <?php echo COLOR_LINK ?> }
     a:active {color: <?php echo COLOR_ALINK ?> }
     a.msg {text-decoration: none; color: <?php echo COLOR_NUM_LINK ?>}
@@ -7,7 +8,7 @@
     }
 
     table.main {
-        background-color: <?php echo COLOR_BG ?>; 
+        background-color: <?php echo COLOR_HEAD ?>; 
         color: <?php echo COLOR_FONT ?>;
         font-family: <?php echo FONT ?>;
         border: thin solid <?php echo COLOR_BG ?>;
@@ -23,21 +24,24 @@
         background-color: <?php echo COLOR_TITLE ?>;
         color: <?php echo COLOR_FONT_TITLE ?>;
         font-weight: bold;               
-        font-size: smaller;
+        font-size: small;
         text-align: left;
     }
     td.title {
         background-color: <?php echo COLOR_ROW_ON ?>;
-        font-size: smaller;
+        font-size: small;
         width: 80%;
     }
     tr.rowoff {
         background-color: <?php echo COLOR_ROW_OFF ?>;
-        font-size: smaller;
+        font-size: small;
     }
     tr.rowon {
         background-color: <?php echo COLOR_ROW_ON ?>;
-        font-size: smaller;
+        font-size: small;
+    }
+    td.row-small {
+        font-size: x-small;
     }
     td.body {
         background-color: <?php echo COLOR_ROW_ON ?>;
diff -ruN ../aero_221_srcfix/themes/blackandblue.theme.inc ./themes/blackandblue.theme.inc
--- ../aero_221_srcfix/themes/blackandblue.theme.inc	1969-12-31 19:00:00.000000000 -0500
+++ ./themes/blackandblue.theme.inc	2004-09-04 15:37:34.000000000 -0400
@@ -0,0 +1,35 @@
+<?php
+
+//----------------------------
+// Default theme include file
+//----------------------------
+
+// font(s) used in AeroMail
+define('FONT', "verdana,arial,helvetica");
+
+// font color
+define('COLOR_FONT', "#FFFFFF");
+
+// background color
+define('COLOR_BG', "#000000");
+
+// color for the header
+define('COLOR_HEAD', "#505090");
+define('COLOR_FONT_HEAD', "#ffffff");
+
+// color for field titles
+define('COLOR_TITLE', "#303050");
+
+// color for colored row
+define('COLOR_ROW_ON', "#202020");
+
+// color for uncolored row
+define('COLOR_ROW_OFF', "#000000");
+
+// link colors
+define('COLOR_LINK', "#dddddd");
+define('COLOR_VLINK', "#999999");
+define('COLOR_ALINK', "#ffffff");
+define('COLOR_NUM_LINK', "#dddddd");
+
+?>
diff -ruN ../aero_221_srcfix/themes/default.template.inc ./themes/default.template.inc
--- ../aero_221_srcfix/themes/default.template.inc	2004-09-04 19:07:31.000000000 -0400
+++ ./themes/default.template.inc	2004-09-04 15:35:51.000000000 -0400
@@ -3,7 +3,7 @@
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
         <title>
-            AeroMail
+            <?php echo PROG_NAME ?>
         </title>
         <?php style() ?>
     </head>
