- /*
- public static class StoredMessage extends Message {
- public int uid;
- public final int uid;
- public final int uidValidity; // must be reset if mailbox is deleted and then recreated
- public final int sequenceNumber; // starts at 1; numbers reshuffled upon EXPUNGE
- public Hash keywords = new Hash();
- public boolean deleted = false;
- public boolean seen = false;
- public boolean flagged = false;
- public boolean draft = false;
- public boolean answered = false;
- public boolean recent = false; // "Message is "recently" arrived in this mailbox. This
- // session is the first session to have been notified
- // about this message;
- public StoredMessage(LineReader rs) throws IOException, MailException.Malformed { super(rs); }
- }
- */
-
- public class Trace {
- final String returnPath;
- final Element[] elements;
- public Trace(LineReader lr) throws Trace.Malformed, IOException {
- String retPath = lr.readLine();
- if (!retPath.startsWith("Return-Path:")) throw new Trace.Malformed("trace did not start with Return-Path header");
- returnPath = retPath.substring(12).trim();
- Vec el = new Vec();
- while(true) {
- String s = lr.readLine();
- if (s == null) break;
- if (!s.startsWith("Received:")) { lr.pushback(s); break; }
- s = s.substring(9).trim();
- el.addElement(new Element(s));
- }
- elements = new Element[el.size()];
- el.copyInto(elements);
- }
- public class Element {
- String fromDomain;
- String fromIP;
- String toDomain;
- String forWhom;
- Date date;
- public Element(String fromDomain, String fromIP, String toDomain, String forWhom, Date date) {
- this.fromDomain=fromDomain; this.fromIP=fromIP; this.toDomain=toDomain; this.forWhom=forWhom; this.date=date; }
- public Element(String s) throws Trace.Malformed {
- StringTokenizer st = new StringTokenizer(s);
- if (!st.nextToken().equals("FROM")) throw new Trace.Malformed("trace did note have a FROM element: " + s);
- fromDomain = st.nextToken();
- if (!st.nextToken().equals("BY")) throw new Trace.Malformed("trace did note have a BY element: " + s);
- toDomain = st.nextToken();
- // FIXME not done yet
- }
- }
- public class Malformed extends Message.Malformed { public Malformed(String s) { super(s); } }
+ public Message withEnvelope(Address from, Address to) {
+ return new Message(this,
+ new String[] {
+ "Return-Path", from==null ? "<>" : from.toString(true),
+ "Envelope-To", to.toString(true)
+ });