--- ../../perfect_maildir.pl	Sun Mar  9 11:08:26 2003
+++ perfect_maildir.pl	Tue Jan 20 20:32:38 2004
@@ -71,9 +71,14 @@
   my $extra = '';
   $extra .= 'F' if $flags =~ /F/; # flagged
   $extra .= 'R' if $flags =~ /A/; # replied
-  $extra .= 'S' if (($flags =~ /R/) || ($flags =~ /O/)); # seen
+#  $extra .= 'S' if (($flags =~ /R/) || ($flags =~ /O/)); # seen
+# Above is an "or", UW-IMAP uses RO for seen combined. O is "old, but not seen, so we want no flags in that case
+# Below fixes, and also accounts for some servers using "U" for old/read or undeleted.
+  $extra .= 'S' if ((($flags =~ /R/) && ($flags =~ /O/)) || ($flags =~ /U/)); # seen
   $extra .= 'T' if $flags =~ /D/; # trashed
-  $file .= ":2,$extra" if $extra;
+#  $file .= ":2,$extra" if $extra;
+# We want the ":2," anyway to show that the message isn't "new" with Dovecot, but has no other status, make unconditional.
+  $file .= ":2,$extra";
 } else {
   $file = "$maildir/new/$time.$num.$hostname";
 }
