bugfixes
[org.ibex.mail.git] / src / org / ibex / mail / Message.java
index 73ab0f8..b1c8e0a 100644 (file)
@@ -176,5 +176,19 @@ public class Message extends MIME.Part {
     public final String summary() { return "[" + envelopeFrom + " -> " + envelopeTo + "] " + subject; }
 
     public static class Malformed extends MailException { public Malformed(String s) { super(s); } }
+
+    /** reads an SMTP-style dot-escaped message */
+    static Message readDotEncodedMessage(Stream conn) {
+        StringBuffer buf = new StringBuffer();
+        while(true) {
+            String s = conn.readln();
+            if (s == null) throw new RuntimeException("connection closed");
+            if (s.equals(".")) break;
+            if (s.startsWith(".")) s = s.substring(1);
+            buf.append(s);
+            buf.append("\r\n");
+        }
+        return Message.newMessage(new Fountain.StringFountain(buf.toString()));
+    }
 }