add a date field if not present (rfc2822 requirement)
[org.ibex.mail.git] / src / org / ibex / mail / Message.java
index 882ca9f..d6ef538 100644 (file)
@@ -100,6 +100,11 @@ public class Message extends MIME.Part {
         this.cc           = Address.list(headers.get("Cc"));
         this.bcc          = Address.list(headers.get("Bcc"));
         this.date         = parseDate(headers.get("Date")) == null ? new Date() : parseDate(headers.get("Date"));
+
+        // RFC2822 requires a "Date" field, so we synthesize one if missing
+        if (headers.get("Date") == null)
+            headers.set("Date", this.date.toString());   // FIXME: formatting
+
         this.arrival      = this.date; // FIXME wrong; grab this from traces?
     }