1 // Copyright 2000-2006 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
9 import org.ibex.mail.target.*;
11 // FIXME FIXME: rate limiting
14 // FIXME: DSN's: RFC 3464 ==> NOTIFY=NEVER
15 // FIXME: MDN's: RFC 3798
17 /** Implements RFC3834-compliant auto-generated messages+replies */
21 public Message autoGenerate() {
22 // same as other, but:
23 ret.headers.put("Auto-Submitted", "auto-generated");
28 * Compose an auto-generated reply compliant with RFC3834.
31 * <b>personal</b>: should be the recipient of the message, might guess from message, MUST be customizable<br>
32 * <b>service</b>: should be a human, and description should describe the service
33 * @param includeAutoInSubject if true; the string "Auto: " is prepended to the subject
35 public Message autoReply(Fountain fountain, Message m, Address autoFrom, boolean includeAutoInSubject) {
37 if (m.envelopeFrom==null) return null;
39 String auto = m.headers.get("auto-submittted");
40 if (auto!=null && !auto.equals("no")) return null;
42 String precedence = m.headers.get("precedence");
43 if (precedence != null) precedence = precedence.trim().toLowerCase();
44 if ("bulk".equals(precedence)) return null;
45 if ("list".equals(precedence)) return null;
46 if ("junk".equals(precedence)) return null;
48 // recommended, not required.
49 if (m.envelopeFrom.user.endsWith("-request")) return null;
50 if (m.envelopeFrom.user.startsWith("owner-")) return null;
51 if (m.envelopeFrom.description.equalsIgnoreCase("mailer-daemon")) return null;
52 for(String key : m.headers.getHeaderNames())
53 if (key.toLowerCase().startsWith("list-")) return null;
55 // SHOULD NOT issue the same response to the same sender more
56 // than once within a period of several days, even though that
57 // sender may have sent multiple messages. A 7-day period is
58 // RECOMMENDED as a default.
60 // Personal and Group responses whose purpose is to notify the
61 // sender of a message of a temporary absence of the recipient
62 // (e.g., "vacation" and "out of the office" notices) SHOULD
63 // NOT be issued unless a valid address for the recipient is
64 // explicitly included in a recipient (e.g., To, Cc, Bcc,
65 // Resent-To, Resent-Cc, or Resent- Bcc) field of the subject
68 throw new Error("FIXME");
70 Message ret = m.reply(fountain, null, false);
72 ret.headers.put("Auto-Submitted", "auto-replied");
73 ret.headers.put("Precedence", "bulk"); // or list
74 ret.headers.put("From", autoFrom);
75 ret.headers.put("Reply-To", autoFrom);
76 if (includeAutoInSubject)
77 ret.headers.put("Subject", "Auto: " + m.subject);
81 // don't return large responses (> a few kb)