]> gitweb.factorcode.org Git - factor.git/blob - basis/smtp/smtp-docs.factor
Add support for AUTH PLAIN to smtp library
[factor.git] / basis / smtp / smtp-docs.factor
1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel quotations help.syntax help.markup
4 io.sockets strings calendar ;
5 IN: smtp
6
7 HELP: smtp-domain
8 { $var-description "The name of the machine that is sending the email.  This variable will be filled in by the " { $link host-name } " word if not set by the user." } ;
9
10 HELP: smtp-server
11 { $var-description "Holds an " { $link inet } " object with the address of an SMTP server." } ;
12
13 HELP: smtp-read-timeout
14 { $var-description "Holds a " { $link duration } " object that specifies how long to wait for a response from the SMTP server." } ;
15
16 HELP: smtp-auth
17 { $var-description "Holds either " { $link no-auth } " or an instance of " { $link plain-auth } ", specifying how to authenticate with the SMTP server. Set to " { $link no-auth } " by default." } ;
18
19 HELP: no-auth
20 { $class-description "If the " { $link smtp-auth } " variable is set to this value, no authentication will be performed." } ;
21
22 HELP: plain-auth
23 { $class-description "If the " { $link smtp-auth } " variable is set to this value, plain authentication will be performed, with the username and password stored in the " { $slot "username" } " and " { $slot "password" } " slots of the tuple sent to the server as plain-text." } ;
24
25 HELP: <plain-auth> ( username password -- plain-auth )
26 { $values { "username" string } { "password" string } { "plain-auth" plain-auth } }
27 { $description "Creates a new " { $link plain-auth } " instance." } ;
28
29 HELP: with-smtp-connection
30 { $values { "quot" quotation } }
31 { $description "Connects to an SMTP server stored in " { $link smtp-server } " and calls the quotation." }
32 { $notes "This word is used to implement " { $link send-email } " and there is probably no reason to call it directly." } ;
33
34 HELP: email
35 { $class-description "An e-mail. E-mails have the following slots:"
36     { $table
37         { { $slot "from" } "The sender of the e-mail. An e-mail address." }
38         { { $slot "to" } "The recipients of the e-mail. A sequence of e-mail addresses." }
39         { { $slot "cc" } "Carbon-copy. A sequence of e-mail addresses." }
40         { { $slot "bcc" } "Blind carbon-copy. A sequence of e-mail addresses." }
41         { { $slot "subject" } " The subject of the e-mail. A string." }
42         { { $slot "body" } " The body of the e-mail. A string." }
43     }
44 "The " { $slot "from" } " and " { $slot "to" } " slots are required; the rest are optional."
45 $nl
46 "An e-mail address is a string in one of the following two formats:"
47 { $list
48     { $snippet "joe@groff.com" }
49     { $snippet "Joe Groff <joe@groff.com>" }
50 } } ;
51
52 HELP: <email>
53 { $values { "email" email } }
54 { $description "Creates an empty " { $link email } " object." } ;
55
56 HELP: send-email
57 { $values { "email" email } }
58 { $description "Sends an e-mail." }
59 { $examples
60     { $code "USING: accessors smtp ;"
61     "<email>"
62     "    \"groucho@marx.bros\" >>from"
63     "    { \"chico@marx.bros\" \"harpo@marx.bros\" } >>to"
64     "    { \"gummo@marx.bros\" } >>cc"
65     "    { \"zeppo@marx.bros\" } >>bcc"
66     "    \"Pickup line\" >>subject"
67     "    \"If I said you had a beautiful body, would you hold it against me?\" >>body"
68     "send-email"
69     ""
70     }
71 } ;
72
73 ARTICLE: "smtp" "SMTP client library"
74 "The " { $vocab-link "smtp" } " vocabulary sends e-mail via an SMTP server."
75 $nl
76 "This library is configured by a set of dynamically-scoped variables:"
77 { $subsection smtp-server }
78 { $subsection smtp-read-timeout }
79 { $subsection smtp-domain }
80 { $subsection smtp-auth }
81 "The latter is set to an instance of one of the following:"
82 { $subsection no-auth }
83 { $subsection plain-auth }
84 "Constructing an e-mail:"
85 { $subsection email }
86 { $subsection <email> }
87 "Sending an email:"
88 { $subsection send-email } ;
89
90 ABOUT: "smtp"