1 USING: smtp tools.test io.streams.string io.sockets threads
2 smtp.server kernel sequences namespaces logging accessors
8 dup clone "a" "b" set-header drop
12 { 0 0 } [ [ ] with-smtp-connection ] must-infer-as
14 [ "hello\nworld" validate-address ] must-fail
16 [ "slava@factorcode.org" ]
17 [ "slava@factorcode.org" validate-address ] unit-test
19 [ { "hello" "." "world" } validate-message ] must-fail
21 [ "hello\r\nworld\r\n.\r\n" ] [
22 "hello\nworld" [ send-body ] with-string-writer
25 [ "500 syntax error" check-response ] must-fail
27 [ ] [ "220 success" check-response ] unit-test
30 "220 success" [ receive-response ] with-string-reader
34 "220-a multiline response\r\n250-another line\r\n220 the end"
35 [ receive-response ] with-string-reader
39 "220-a multiline response\r\n250-another line\r\n220 the end"
40 [ get-ok ] with-string-reader
44 "Subject:\r\nsecurity hole" validate-header
49 { "From" "Doug <erg@factorcode.org>" }
50 { "Subject" "Factor rules" }
51 { "To" "Slava <slava@factorcode.org>, Ed <dharmatech@factorcode.org>" }
53 { "slava@factorcode.org" "dharmatech@factorcode.org" }
57 "Factor rules" >>subject
59 "Slava <slava@factorcode.org>"
60 "Ed <dharmatech@factorcode.org>"
62 "Doug <erg@factorcode.org>" >>from
64 dup headers>> >alist sort-keys [
65 drop { "Date" "Message-Id" } member? not
71 [ ] [ [ 4321 mock-smtp-server ] "SMTP server" spawn drop ] unit-test
73 [ ] [ yield ] unit-test
77 "localhost" 4321 <inet> smtp-server set
80 "Hi guys\nBye guys" >>body
81 "Factor rules" >>subject
83 "Slava <slava@factorcode.org>"
84 "Ed <dharmatech@factorcode.org>"
86 "Doug <erg@factorcode.org>" >>from
91 [ ] [ yield ] unit-test