add allmail to gather copies of all messages passing through the server
authoradam <adam@megacz.com>
Sat, 1 Mar 2008 06:01:05 +0000 (06:01 +0000)
committeradam <adam@megacz.com>
Sat, 1 Mar 2008 06:01:05 +0000 (06:01 +0000)
darcs-hash:20080301060105-5007d-c6d94c9062465ed68c7e72e84a4a1eeffbcc1a69.gz

src/org/ibex/mail/SMTP.java

index 9ca85c8..64677a0 100644 (file)
@@ -46,6 +46,10 @@ public class SMTP {
     public static final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
     public static final int numOutgoingThreads = 5;
 
+    private static final SqliteMailbox allmail =
+        (SqliteMailbox)FileBasedMailbox
+        .getFileBasedMailbox("/afs/megacz.com/mail/user/megacz/allmail", false);
+
     public static final int GRAYLIST_MINWAIT =  1000 * 60 * 60;           // one hour
     public static final int GRAYLIST_MAXWAIT =  1000 * 60 * 60 * 24 * 5;  // five days
 
@@ -73,7 +77,16 @@ public class SMTP {
 
     public static void enqueue(Message m) throws IOException {
         if (!m.envelopeTo.isLocal()) Outgoing.enqueue(m);
-        else                         Target.root.accept(m);
+        else {
+            try {
+                allmail.accept(m);
+            } catch (Exception e) {
+                // FIXME incredibly gross hack
+                if (e.toString().indexOf("attempt to insert two messages with identical messageid")==-1)
+                    Log.error(SMTP.class, e);
+            }
+            Target.root.accept(m);
+        }
     }
 
     public static class SMTPException extends MailException {