File target = new File(name);
File f = new File(target.getCanonicalPath() + "-");
FileOutputStream fo = new FileOutputStream(f);
- message.dump(new Stream(fo));
+ Stream stream = new Stream(fo);
+ stream.println("X-org.ibex.mail.headers.envelope.From: " + message.envelope.from);
+ stream.println("X-org.ibex.mail.headers.envelope.To: " + message.envelope.to);
+ message.dump(stream);
fo.close();
f.renameTo(target);
Log.info(this, " done writing.");
try {
File file = new File(path + File.separatorChar + names[cur]);
FileInputStream fis = new FileInputStream(file);
- Message ret = new Message(null, null, new Stream(fis));
+ Stream stream = new Stream(fis);
+ Address envelopeFrom = null;
+ Address envelopeTo = null;
+ for(String s = stream.readln(); s != null; s = stream.readln()) {
+ if (s.startsWith("X-org.ibex.mail.headers.envelope.From: "))
+ envelopeFrom = Address.parse(s.substring(38).trim());
+ else if (s.startsWith("X-org.ibex.mail.headers.envelope.To: "))
+ envelopeTo = Address.parse(s.substring(36).trim());
+ else {
+ stream.unread(s + "\r\n");
+ break;
+ }
+ }
+ Message ret = new Message(stream,
+ new Message.Envelope(envelopeFrom, envelopeTo, new Date(file.lastModified())));
fis.close();
return ret;
} catch (IOException e) { throw new MailException.IOException(e);