diff -ruN ../am222-srcfix/changes ./changes
--- ../am222-srcfix/changes	2004-09-09 23:45:47.000000000 -0400
+++ ./changes	2004-09-09 23:49:32.000000000 -0400
@@ -124,3 +124,32 @@
 * Some HTML tweaks
 * Made whole line bold for new messages, through CSS
 * Limit spam check to unread messages for speed
+
+Version 2.23 - Laird Bedore
+
+Functionality:
+* Added support and configuration for SSL-encrypted IMAP servers
+* Enhanced FORCE_FROM to work with systems where the mail domain is 
+  different than the IMAP_SERVER value - can optionally configure the 
+  SERVER_SUFFIX variable, if different than IMAP_SERVER
+* Enhanced local addressing and save-to-sent-items to also use the 
+  SERVER_SUFFIX if defined
+* Fixed an infinite loop generated by some inline images
+Cosmetics:
+* Tweaked the font sizes for better-emphasized readability, forced the
+  date and size fields to never line-break.
+* Adjusted the table 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
+* Changed background color of table.main (the lines inbetween table cells).
+  Looks much better on all themes.
+* Added missing body style information, greatly simplified the automatic
+  centering and bordering of the mail table
+Features:
+* Added option to hide the To: field if it is not desired on folders other
+  than the sent items folder.
+* 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 ../am222-srcfix/config.inc ./config.inc
--- ../am222-srcfix/config.inc	2004-09-09 23:45:50.000000000 -0400
+++ ./config.inc	2004-09-09 23:50:29.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,26 @@
 // AeroMail let sendmail and genericstable figure it out (0=no 1=yes)
 define('FORCE_FROM', 1);
 
+// If you are using the FORCE_FROM but your path to your mail domain is
+// different than the IMAP_SERVER setting above, you can define a server 
+// suffix. It will send as user@SERVER_SUFFIX instead of user@IMAP_SERVER
+// define('SERVER_SUFFIX',"mydomain.com");
+
+// Should AeroMail display the To: field when listing messsages in 
+// folders other than Sent Items? 0 is no, 1 is yes (default)
+define('DISPLAY_TO_FIELD',1);
+
+// 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 ../am222-srcfix/folder.php ./folder.php
--- ../am222-srcfix/folder.php	2004-09-09 23:45:52.000000000 -0400
+++ ./folder.php	2004-09-09 20:32:08.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 ../am222-srcfix/global.inc ./global.inc
--- ../am222-srcfix/global.inc	2004-09-09 23:45:55.000000000 -0400
+++ ./global.inc	2004-09-09 23:57:51.000000000 -0400
@@ -1,12 +1,12 @@
 <?php
 
 // shouldn't have to modify anything in this file...
-define('VERSION', "AeroMail 2.22");
+define('VERSION', "AeroMail 2.23");
 
 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 = hemlspecialchars(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;
@@ -630,6 +639,47 @@
     return htmlspecialchars($url);
 }
 
+function forcelinebreaks($dsp,$charcount) {
+  /* lastLB = lask-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)) {
+        // Jump 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 . "\"");
@@ -654,9 +704,7 @@
         $mailbox = mailbox_log_in($folder);
 
         if(!$mailbox)
-        {
             login_prompt();
-        }
     }
 } 
 
diff -ruN ../am222-srcfix/index.php ./index.php
--- ../am222-srcfix/index.php	2004-09-09 23:45:58.000000000 -0400
+++ ./index.php	2004-09-09 22:24:09.000000000 -0400
@@ -235,6 +235,7 @@
             echo "<img src=\"images/descending.gif\" alt=\"v\" width=\"8\" height=\"8\" border=\"0\">";
         title_left_end();
     }
+  if (DISPLAY_TO_FIELD || $issentmail) {
     title_left();
     echo "<a href=\"";
     if ($sort == SORTTO)
@@ -250,6 +251,7 @@
     if ($sort == 100 + SORTTO)
         echo "<img src=\"images/descending.gif\" alt=\"v\" width=\"8\" height=\"8\" border=\"0\">";
     title_left_end();
+  }
     title_left();
     echo "<a href=\"";
     if ($issentmail)
@@ -414,17 +416,19 @@
                 echo L_NO_FROM;
             body_left_end();
         }
+      if ($issentmail || DISPLAY_TO_FIELD) {
         body_left();
         if ($msg->to)
             echo make_clickable_list($msg->to, $folder);
         else
             echo L_NO_TO;
         body_left_end();
-        body_left();
-        echo date(L_DATE_FORMAT, $msg->udate);
+      }
+        body_left('class="row-small"');
+        echo "<nobr>".date(L_DATE_FORMAT, $msg->udate)."</nobr>";
         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 ../am222-srcfix/lang/en.lang.inc ./lang/en.lang.inc
--- ../am222-srcfix/lang/en.lang.inc	2004-09-09 23:46:05.000000000 -0400
+++ ./lang/en.lang.inc	2004-09-09 23:39:27.000000000 -0400
@@ -43,7 +43,7 @@
 define('L_FOLDER_BTN', "Folders");
 define('L_DELETE_BTN', "Delete");
 define('L_COMPOSE_BTN', "Compose");
-define('L_LOGOUT_BTN', "Login");
+define('L_LOGOUT_BTN', "Logout");
 define('L_REPLY_BTN', "Reply");
 define('L_REPLYALL_BTN', "Reply All");
 define('L_FORWARD_BTN', "Forward");
diff -ruN ../am222-srcfix/layout.inc ./layout.inc
--- ../am222-srcfix/layout.inc	2004-09-09 23:46:17.000000000 -0400
+++ ./layout.inc	2004-09-09 21:07:57.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
 }
diff -ruN ../am222-srcfix/send_message.php ./send_message.php
--- ../am222-srcfix/send_message.php	2004-09-09 23:46:25.000000000 -0400
+++ ./send_message.php	2004-09-09 23:41:00.000000000 -0400
@@ -22,14 +22,26 @@
        in bas64 except in the end.
     */
     $boundary = "=_Message-Boundary_=";
+    $mailheaders = "";
+
+    if (FORCE_FROM && is_string(SERVER_SUFFIX)) {
+        $mailheaders .= "From: $user@".SERVER_SUFFIX."\r\n";
+        //$mailheaders .= "Reply-To: $user@".SERVER_SUFFIX."\r\n";
+    }
 
     $to = stripslashes($to);
     $to = removecrlf($to);
     if (!strstr($to, "@"))
     {
-        $to .= "@" . IMAP_SERVER;
+        if (is_string(SERVER_SUFFIX)) {
+echo "Using server suffix " . SERVER_SUFFIX . "<br>\n";
+            $to .= "@" . SERVER_SUFFIX;
+        } else {
+echo "Defaulting to IMAP server " . IMAP_SERVER . "<br>\n";
+            $to .= "@" . IMAP_SERVER;
+        }
     }
-    $mailheaders = "To: ".removecrlf($to)."\r\n";
+    $mailheaders .= "To: ".removecrlf($to)."\r\n";
     
     $cc = stripslashes($cc);
     $mailheaders .= "Cc: ".removecrlf($cc)."\r\n";
@@ -79,8 +91,10 @@
 
     $mailheaders .= "\r\n";
 
-    $from_user = FORCE_FROM ? "$user@" . IMAP_SERVER : $user;
-
+    if (is_string(SERVER_SUFFIX))
+        $from_user = FORCE_FROM ? "$user@" . SERVER_SUFFIX : $user;
+    else
+        $from_user = FORCE_FROM ? "$user@" . IMAP_SERVER : $user;
     mailfrom($from_user, $msg_body, $mailheaders);
 
     // add message to the sent mail folder
@@ -98,7 +112,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 (is_string(SERVER_SUFFIX))
+            $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 ../am222-srcfix/style.php ./style.php
--- ../am222-srcfix/style.php	2004-09-09 23:46:27.000000000 -0400
+++ ./style.php	2004-09-09 22:27:25.000000000 -0400
@@ -1,4 +1,5 @@
 <style type="text/css">
+    body {margin-top: 11; margin-left: 11; margin-right: 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 ?>;
@@ -20,13 +21,13 @@
         font-size: larger;
     }
     table.body {
-        font-size: smaller;
+        font-size: small;
     }
     th.title {
         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 {
@@ -35,21 +36,24 @@
     }
     tr.rowoffnew {
         background-color: <?php echo COLOR_ROW_OFF ?>;
-        font-size: smaller;
+        font-size: small;
         font-weight: bold;
     }
     tr.rowonnew {
         background-color: <?php echo COLOR_ROW_ON ?>;
-        font-size: smaller;
+        font-size: small;
         font-weight: bold;
     }
     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 ?>;
@@ -59,7 +63,7 @@
     td.version {
         background-color: <?php echo COLOR_BG ?>; 
         color: <?php echo COLOR_FONT ?>;
-        font-size: smaller;
+        font-size: x-small;
         font-style: italic;
         text-align: center;
     }
diff -ruN ../am222-srcfix/themes/blackandblue.theme.inc ./themes/blackandblue.theme.inc
--- ../am222-srcfix/themes/blackandblue.theme.inc	1969-12-31 19:00:00.000000000 -0500
+++ ./themes/blackandblue.theme.inc	2004-09-09 21:31:45.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 ../am222-srcfix/themes/default.template.inc ./themes/default.template.inc
--- ../am222-srcfix/themes/default.template.inc	2004-09-09 23:46:13.000000000 -0400
+++ ./themes/default.template.inc	2004-09-09 21:54:30.000000000 -0400
@@ -3,18 +3,14 @@
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
         <title>
-            AeroMail
+            <?php echo PROG_NAME ?>
         </title>
         <?php style() ?>
     </head>
 
-    <body bgcolor="#3399CC">
-    <div align="center">
-    <div style="width:90%">
-        <br><br>
+    <body>
+      <center>
         <?php content(); ?>
-        <br><br>
-    </div>
-    </div>
+      </center>
     </body>
 </html>
