-public class Message extends JSReflection {
-
- public final String allHeaders; // pristine headers
- public final Hashtable headers; // hash of headers (not including resent's and traces)
- public final String body; // entire body
-
- // parsed header fields
- public final Date date;
- public final Address to;
- public final Address from; // if multiple From entries, this is sender
- public final Address replyto; // if none provided, this is equal to sender
- public final String subject;
- public final String messageid;
- public final Address[] cc;
- public final Address[] bcc;
- public final Hashtable[] resent;
- public final Trace[] traces;
-
- // envelope fields
- public final Address envelopeFrom;
- public final Address[] envelopeTo;
-
- public void dump(OutputStream os) {
- Log.error(this, "not implemented");
- }
-
- public static class StoredMessage extends Message {
- public StoredMessage(/*ReadStream rs*/SMTP.LineReader rs, boolean dotTerminatedLikeSMTP) throws IOException {
- super(rs, dotTerminatedLikeSMTP); uid = -1; }
- public final int uid;
- public boolean deleted = false;
- public boolean read = false;
- public boolean answered = false;
- public String dumpStoredForm() { throw new Error("StoredMessage.dumpStoredForm() not implemented"); };
- public static StoredMessage undump(InputStream os) {
- Log.error(StoredMessage.class, "not implemented");
- return null;
- }
+/**
+ * [immutable] This class encapsulates a message "floating in the
+ * ether": RFC2822 data but no storage-specific flags or other
+ * metadata.
+ */
+public class Message extends MIME.Part {
+
+ // Parsed Headers //////////////////////////////////////////////////////////////////////////////
+
+ public final Address to;
+ public final Address from; // if multiple From entries, this is sender
+ public final Address envelopeFrom;
+ public final Address envelopeTo;
+ public final Date date;
+ public final Date arrival;
+ public final Address replyto; // if none provided, this is equal to sender
+ public final String subject;
+ public final String messageid;
+ public final Address[] cc;
+ public final Address[] bcc;
+
+ public static Message newMessage(Fountain in) throws Malformed { return new Message(in); }
+
+ /*
+ public Message reply(Fountain in, Address from, boolean includeReInSubject) throws Malformed {
+ Address to = null;
+ if (to==null) to = Address.parse(headers.get("reply-to"));
+ if (to==null) to = Address.parse(headers.get("from"));
+ if (to==null) to = envelopeFrom;
+ if (to==null) throw new Malformed("cannot reply to a message without a return address");
+ Message ret = newMessage(in, from, to);
+ ret.headers.put("In-Reply-To", messageid);
+ String references = headers.get("references");
+ ret.headers.put("References", messageid + (references==null?"":(" "+references)));
+ if (includeReInSubject && subject!=null && !subject.toLowerCase().trim().startsWith("re:"))
+ headers.put("subject", "Re: "+subject);
+ return ret;