Support for multi-line responses.
[lambdamail.git] / lambdamail.scm
index c3a68c1..49fbaec 100644 (file)
@@ -17,7 +17,7 @@
         (chicken sort)
         srfi-1 srfi-13 matchable base64)
 
-(define lambdamail-version "LambdaMail v1.2.0")
+(define lambdamail-version "LambdaMail v1.3.0")
 
 (define-record config host port spool-dir user group)
 (define-record message to from text user password)
 (define ((make-outgoing-smtp-session tcp-in tcp-out) . command)
   (match command
     (('expect codes ...)
-     (let ((result (read-line tcp-in)))
-       (print "Expecting one of " codes " got " result)
-       (or-list (map (lambda (code) (string-prefix? code result)) codes))))
+     (let loop ((result (read-line tcp-in)))
+       (if (and (> (string-length result) 3)
+                (eq? (string-ref result 3) #\-))
+           (loop (read-line tcp-in)) ;status continues on next line
+           (begin
+             (print "Expecting one of " codes " got " result)
+             (or-list (map (lambda (code)
+                             (string-prefix? code result))
+                           codes))))))
     (('send strings ...)
      (print "Sending " (if (> (string-length (car strings)) 30)
                            (string-take (car strings) 30)