--- /dev/null
+// Copyright 2000-2006 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
+
+package org.ibex.mail;
+import java.io.*;
+import java.util.*;
+import org.ibex.js.*;
+import org.ibex.mail.target.*;
+
+// FIXME FIXME: rate limiting
+
+
+// FIXME: DSN's: RFC 3464 ==> NOTIFY=NEVER
+// FIXME: MDN's: RFC 3798
+
+/** Implements RFC3834-compliant auto-generated messages+replies */
+public class Auto {
+
+ /*
+ public Message autoGenerate() {
+ // same as other, but:
+ ret.headers.put("Auto-Submitted", "auto-generated");
+ }
+ */
+
+ /**
+ * Compose an auto-generated reply compliant with RFC3834.
+ *
+ * @param from
+ * <b>personal</b>: should be the recipient of the message, might guess from message, MUST be customizable<br>
+ * <b>service</b>: should be a human, and description should describe the service
+ * @param includeAutoInSubject if true; the string "Auto: " is prepended to the subject
+ */
+ public Message autoReply(Fountain fountain, Message m, Address autoFrom, boolean includeAutoInSubject) {
+
+ if (m.envelopeFrom==null) return null;
+
+ String auto = m.headers.get("auto-submittted");
+ if (auto!=null && !auto.equals("no")) return null;
+
+ String precedence = m.headers.getLowerCaseTrimmed("precedence");
+ if ("bulk".equals(precedence)) return null;
+ if ("list".equals(precedence)) return null;
+ if ("junk".equals(precedence)) return null;
+
+ // recommended, not required.
+ if (m.envelopeFrom.user.endsWith("-request")) return null;
+ if (m.envelopeFrom.user.startsWith("owner-")) return null;
+ if (m.envelopeFrom.description.equalsIgnoreCase("mailer-daemon")) return null;
+ for(Enumeration e = m.headers.names(); e.hasMoreElements();) {
+ String key = (String)e.nextElement();
+ if (key.toLowerCase().startsWith("list-")) return null;
+ }
+
+ // SHOULD NOT issue the same response to the same sender more
+ // than once within a period of several days, even though that
+ // sender may have sent multiple messages. A 7-day period is
+ // RECOMMENDED as a default.
+
+ // Personal and Group responses whose purpose is to notify the
+ // sender of a message of a temporary absence of the recipient
+ // (e.g., "vacation" and "out of the office" notices) SHOULD
+ // NOT be issued unless a valid address for the recipient is
+ // explicitly included in a recipient (e.g., To, Cc, Bcc,
+ // Resent-To, Resent-Cc, or Resent- Bcc) field of the subject
+ // message.
+
+ throw new Error("FIXME");
+ /*
+ Message ret = m.reply(fountain, null, false);
+
+ ret.headers.put("Auto-Submitted", "auto-replied");
+ ret.headers.put("Precedence", "bulk"); // or list
+ ret.headers.put("From", autoFrom);
+ ret.headers.put("Reply-To", autoFrom);
+ if (includeAutoInSubject)
+ ret.headers.put("Subject", "Auto: " + m.subject);
+ */
+ }
+
+ // don't return large responses (> a few kb)
+
+}