     [ "Bad e-mail address: " prepend throw ] unless ;
 
 : mail-from ( fromaddr -- )
-    "MAIL FROM:<" write validate-address write ">" write crlf ;
+    "MAIL FROM:<" swap validate-address ">" 3append command ;
 
 : rcpt-to ( to -- )
-    "RCPT TO:<" write validate-address write ">" write crlf ;
+    "RCPT TO:<" swap validate-address ">" 3append command ;
 
 : data ( -- )
-    "DATA" write crlf ;
+    "DATA" command ;
 
 : validate-message ( msg -- msg' )
     "." over member? [ "Message cannot contain . on a line by itself" throw ] when ;

    string-lines
    validate-message
    [ write crlf ] each
    "." write crlf ;

: quit ( -- )
    "QUIT" write crlf ;

LOG: smtp-response DEBUG


IN: smtp

SYMBOL: smtp-domain
SYMBOL: smtp-server     "localhost" "smtp" <inet> smtp-server set-global
SYMBOL: read-timeout    1 minutes read-timeout set-global
SYMBOL: esmtp           t esmtp set-global

