public void dump(OutputStream os) throws IOException {
Writer w = new OutputStreamWriter(os);
w.write(allHeaders);
+ w.write("X-IbexMail-EnvelopeFrom: " + envelopeFrom + "\r\n");
+ w.write("X-IbexMail-EnvelopeTo: "); for(int i=0; i<envelopeTo.length; i++) w.write(envelopeTo[i] + " "); w.write("\r\n");
w.write("\r\n");
w.write(body);
w.flush();
}
if (s.indexOf(':') == -1) throw new Malformed("Header line does not contain colon: " + s);
key = s.substring(0, s.indexOf(':'));
- for(int i=0; i<s.length(); i++)
- if (s.charAt(i) < 33 || s.charAt(i) > 126)
- throw new Malformed("Header key contains invalid character \"" + s.charAt(i) + "\"");
- String val = s.substring(0, s.indexOf(':'));
+ for(int i=0; i<key.length(); i++)
+ if (key.charAt(i) < 33 || key.charAt(i) > 126)
+ throw new Malformed("Header key \""+key+"\" contains invalid character \"" + key.charAt(i) + "\"");
+ String val = s.substring(s.indexOf(':') + 1).trim();
while(Character.isSpace(val.charAt(0))) val = val.substring(1);
if (key.startsWith("Resent-")) {
if (key.startsWith("Resent-From")) resent.addElement(new Hashtable());
}
this.date = (Date)headers.get("Date");
- this.to = new Address((String)headers.get("To"));
- this.from = new Address((String)headers.get("From"));
- this.replyto = new Address((String)headers.get("Reply-To"));
+ this.to = new Address((String)headers.get("To")); // FIXME what if null?
+ this.from = headers.get("From") == null ? envelopeFrom : new Address((String)headers.get("From"));
+ this.replyto = headers.get("Reply-To") == null ? null : new Address((String)headers.get("Reply-To"));
this.subject = (String)headers.get("Subject");
this.messageid = (String)headers.get("Message-Id");
if (headers.get("Cc") != null) {