import java.io.*;
import java.util.*;
import org.ibex.js.*;
-import org.ibex.mail.target.*;
+import org.ibex.io.*;
+import org.ibex.io.Fountain;
// FIXME FIXME: rate limiting
-
// FIXME: DSN's: RFC 3464 ==> NOTIFY=NEVER
// FIXME: MDN's: RFC 3798
-/** Implements RFC3834-compliant auto-generated messages+replies */
+// FIXME
+// 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.
+
+// FIXME: be sure to never, ever return large responses (> a few kb)
+
+/** Implements RFC3834-safe/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 message (not a 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 autoGenerate(Headers headers, Fountain body, Address autoFrom, Address autoTo, boolean includeAutoInSubject) {
+ return Message.newMessageFromHeadersAndBody(new Headers(headers, new String[] {
+ "Auto-Submitted", "auto-generated",
+ "Precedence", "bulk",
+ "Subject", (includeAutoInSubject ? "Auto: " : "")+headers.get("subject"),
+ "From", autoFrom.toString(true),
+ "Reply-To", autoFrom.toString(false)
+ }),
+ body, null, autoTo);
}
- */
/**
* Compose an auto-generated reply compliant with RFC3834.
for(String key : m.headers.getHeaderNames())
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);
- */
+ return m.reply(new String[] {
+ "Auto-Submitted", "auto-replied",
+ "Precedence", "bulk",
+ "Subject", (includeAutoInSubject ? "Auto: " : "")+m.subject,
+ "From", autoFrom.toString(true),
+ "Reply-To", autoFrom.toString(false)
+ },
+ fountain, null, false);
}
- // don't return large responses (> a few kb)
-
}