+ // FIXME: untested. Do we really want to duplicate all the old headers???
+ public Message reply(Fountain body, Address from, boolean includeReInSubject) throws Malformed {
+ return reply(new String[0], body, from, includeReInSubject);
+ }
+ public Message reply(String[] keyval, Fountain body, Address envelopeFrom, 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 = this.envelopeFrom;
+ if (to==null) throw new Malformed("cannot reply to a message without a return address");
+ String references = headers.get("references");
+ String subject = this.subject;
+ if (includeReInSubject && subject!=null && !subject.toLowerCase().trim().startsWith("re:"))
+ subject = "Re: "+subject;
+ Headers h = new Headers(new Headers(new String[] {
+ "To", to.toString(true),
+ "Message-Id", generateFreshMessageId(),
+ "Date", new Date()+"" /*FIXME!!!*/,
+ "Subject", subject,
+ "In-Reply-To", messageid,
+ "References", messageid + (references==null?"":(" "+references))
+ }), keyval);
+ return newMessageFromHeadersAndBody(h, body, from, to);