diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-16 20:41:03 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-16 20:41:03 +0000 |
commit | ba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc (patch) | |
tree | 1a49ac4a3c74b9d3bf8e4220d4bf9c48641f3dbc /doc/smtp.html | |
parent | 0a4c1534f39511894728da193ab8225ad6022de9 (diff) | |
download | luasocket-ba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc.tar.gz luasocket-ba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc.tar.bz2 luasocket-ba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc.zip |
Fine tuning the manual...
Diffstat (limited to 'doc/smtp.html')
-rw-r--r-- | doc/smtp.html | 77 |
1 files changed, 49 insertions, 28 deletions
diff --git a/doc/smtp.html b/doc/smtp.html index 0fdc4a4..6b348e0 100644 --- a/doc/smtp.html +++ b/doc/smtp.html | |||
@@ -35,8 +35,15 @@ | |||
35 | 35 | ||
36 | <h2 id=smtp>SMTP</h2> | 36 | <h2 id=smtp>SMTP</h2> |
37 | 37 | ||
38 | <p> The <tt>smtp.lua</tt> module provides functionality to send e-mail | 38 | <p> The <tt>smtp</tt> namespace provides functionality to send e-mail |
39 | messages. The implementation conforms to the Simple Mail Transfer Protocol, | 39 | messages. The high-level API consists of two functions: one to |
40 | define an e-mail message, and another to actually send the message. | ||
41 | Although almost all users will find that these functions provide more than | ||
42 | enough functionality, the underlying implementation allows for even more | ||
43 | control (if you bother to read the code). | ||
44 | </p> | ||
45 | |||
46 | <p>The implementation conforms to the Simple Mail Transfer Protocol, | ||
40 | <a href="http://www.cs.princeton.edu/~diego/rfc/rfc2821.txt">RFC 2821</a>. | 47 | <a href="http://www.cs.princeton.edu/~diego/rfc/rfc2821.txt">RFC 2821</a>. |
41 | Another RFC of interest is <a | 48 | Another RFC of interest is <a |
42 | href="http://www.cs.princeton.edu/~diego/rfc/rfc2822.txt">RFC 2822</a>, | 49 | href="http://www.cs.princeton.edu/~diego/rfc/rfc2822.txt">RFC 2822</a>, |
@@ -52,6 +59,15 @@ sources and sinks</a> and the <a href=mime.html>MIME</a> module is | |||
52 | assumed. In fact, the SMTP module was the main reason for their | 59 | assumed. In fact, the SMTP module was the main reason for their |
53 | creation. </p> | 60 | creation. </p> |
54 | 61 | ||
62 | <p> | ||
63 | To obtain the <tt>smtp</tt> namespace, run: | ||
64 | </p> | ||
65 | |||
66 | <pre class=example> | ||
67 | -- loads the SMTP module and everything it requires | ||
68 | local smtp = require("smtp") | ||
69 | </pre> | ||
70 | |||
55 | <p> | 71 | <p> |
56 | MIME headers are represented as a Lua table in the form: | 72 | MIME headers are represented as a Lua table in the form: |
57 | </p> | 73 | </p> |
@@ -62,12 +78,8 @@ MIME headers are represented as a Lua table in the form: | |||
62 | headers = {<br> | 78 | headers = {<br> |
63 | field-1-name = <i>field-1-value</i>,<br> | 79 | field-1-name = <i>field-1-value</i>,<br> |
64 | field-2-name = <i>field-2-value</i>,<br> | 80 | field-2-name = <i>field-2-value</i>,<br> |
65 | field-3-name = <i>field-3-value</i>, | 81 | field-3-name = <i>field-3-value</i>,<br> |
66 | </tt></td></tr> | 82 | ...<br> |
67 | <tr><td align=center><tt> | ||
68 | ... | ||
69 | </tt></td></tr> | ||
70 | <tr><td><tt> | ||
71 | field-n-name = <i>field-n-value</i><br> | 83 | field-n-name = <i>field-n-value</i><br> |
72 | } | 84 | } |
73 | </tt></td></tr> | 85 | </tt></td></tr> |
@@ -105,12 +117,12 @@ smtp.<b>send{</b><br> | |||
105 | from = <i>string</i>,<br> | 117 | from = <i>string</i>,<br> |
106 | rcpt = <i>string</i> or <i>string-table</i>,<br> | 118 | rcpt = <i>string</i> or <i>string-table</i>,<br> |
107 | source = <i>LTN12 source</i>,<br> | 119 | source = <i>LTN12 source</i>,<br> |
108 | [user = <i>string</i>],<br> | 120 | [user = <i>string</i>,]<br> |
109 | [password = <i>string</i>],<br> | 121 | [password = <i>string</i>,]<br> |
110 | [server = <i>string</i>],<br> | 122 | [server = <i>string</i>,]<br> |
111 | [port = <i>string</i>]<br> | 123 | [port = <i>string</i>,]<br> |
112 | [domain = <i>string</i>],<br> | 124 | [domain = <i>string</i>,]<br> |
113 | [step = <i>LTN12 pump step</i>],<br> | 125 | [step = <i>LTN12 pump step</i>,]<br> |
114 | <b>}</b> | 126 | <b>}</b> |
115 | </p> | 127 | </p> |
116 | 128 | ||
@@ -127,8 +139,9 @@ The sender is given by the e-mail address in the <tt>from</tt> field. | |||
127 | <tt>Rcpt</tt> is a Lua table with one entry for each recipient e-mail | 139 | <tt>Rcpt</tt> is a Lua table with one entry for each recipient e-mail |
128 | address, or a string | 140 | address, or a string |
129 | in case there is just one recipient. | 141 | in case there is just one recipient. |
130 | The contents of the message are given by a <em>simple</em> LTN12 <tt>source</tt>. Several | 142 | The contents of the message are given by a <em>simple</em> |
131 | arguments are optional: | 143 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> |
144 | <tt>source</tt>. Several arguments are optional: | ||
132 | </p> | 145 | </p> |
133 | <ul> | 146 | <ul> |
134 | <li> <tt>user</tt>, <tt>password</tt>: User and password for | 147 | <li> <tt>user</tt>, <tt>password</tt>: User and password for |
@@ -138,7 +151,9 @@ methods if supported by the server (both are unsafe); | |||
138 | <li> <tt>port</tt>: Port to connect to. Defaults to 25; | 151 | <li> <tt>port</tt>: Port to connect to. Defaults to 25; |
139 | <li> <tt>domain</tt>: Domain name used to greet the server; Defaults to the | 152 | <li> <tt>domain</tt>: Domain name used to greet the server; Defaults to the |
140 | local machine host name; | 153 | local machine host name; |
141 | <li> <tt>step</tt>: LTN12 pump step function used to pass data from the | 154 | <li> <tt>step</tt>: |
155 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
156 | pump step function used to pass data from the | ||
142 | source to the server. Defaults to the LTN12 <tt>pump.step</tt> function. | 157 | source to the server. Defaults to the LTN12 <tt>pump.step</tt> function. |
143 | </ul> | 158 | </ul> |
144 | 159 | ||
@@ -166,7 +181,8 @@ exact opposite of what you expect. | |||
166 | Only recipients specified in the <tt>rcpt</tt> list will receive a copy of the | 181 | Only recipients specified in the <tt>rcpt</tt> list will receive a copy of the |
167 | message. Each recipient of an SMTP mail message receives a copy of the | 182 | message. Each recipient of an SMTP mail message receives a copy of the |
168 | message body along with the headers, and nothing more. The headers | 183 | message body along with the headers, and nothing more. The headers |
169 | <em>are</em> part of the message and should be produced by the LTN12 | 184 | <em>are</em> part of the message and should be produced by the |
185 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
170 | <tt>source</tt> function. The <tt>rcpt</tt> list is <em>not</em> | 186 | <tt>source</tt> function. The <tt>rcpt</tt> list is <em>not</em> |
171 | part of the message and will not be sent to anyone. | 187 | part of the message and will not be sent to anyone. |
172 | </p> | 188 | </p> |
@@ -258,8 +274,8 @@ smtp.<b>message(</b>mesgt<b>)</b> | |||
258 | </p> | 274 | </p> |
259 | 275 | ||
260 | <p class=description> | 276 | <p class=description> |
261 | Returns a LTN12 source that sends an SMTP message body, possibly multipart | 277 | Returns a <em>simple</em> |
262 | (arbitrarily deep). | 278 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> source that sends an SMTP message body, possibly multipart (arbitrarily deep). |
263 | </p> | 279 | </p> |
264 | 280 | ||
265 | <p class=parameters> | 281 | <p class=parameters> |
@@ -277,12 +293,12 @@ mesgt = {<br> | |||
277 | }<br> | 293 | }<br> |
278 | <br> | 294 | <br> |
279 | multipart-mesgt = {<br> | 295 | multipart-mesgt = {<br> |
280 | preamble = <i>string</i><br> | 296 | [preamble = <i>string</i>,]<br> |
281 | [1] = <i>mesgt</i>,<br> | 297 | [1] = <i>mesgt</i>,<br> |
282 | [2] = <i>mesgt</i>,<br> | 298 | [2] = <i>mesgt</i>,<br> |
283 | ...<br> | 299 | ...<br> |
284 | [<i>n</i>] = <i>mesgt</i>,<br> | 300 | [<i>n</i>] = <i>mesgt</i>,<br> |
285 | epilogue = <i>string</i>,<br> | 301 | [epilogue = <i>string</i>,]<br> |
286 | }<br> | 302 | }<br> |
287 | </tt></td></tr> | 303 | </tt></td></tr> |
288 | </table> | 304 | </table> |
@@ -291,14 +307,19 @@ multipart-mesgt = {<br> | |||
291 | <p class=parameters> | 307 | <p class=parameters> |
292 | For a simple message, all that is needed is a set of <tt>headers</tt> | 308 | For a simple message, all that is needed is a set of <tt>headers</tt> |
293 | and the <tt>body</tt>. The message <tt>body</tt> can be given as a string | 309 | and the <tt>body</tt>. The message <tt>body</tt> can be given as a string |
294 | or as a LTN12 source. For multipart messages, the body is a table that | 310 | or as a <em>simple</em> |
295 | recursively defines each part as an independent message, plus a preamble | 311 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> |
296 | and an epilogue. | 312 | source. For multipart messages, the body is a table that |
313 | recursively defines each part as an independent message, plus an optional | ||
314 | <tt>preamble</tt> and <tt>epilogue</tt>. | ||
297 | </p> | 315 | </p> |
298 | 316 | ||
299 | <p class=return> | 317 | <p class=return> |
300 | The function returns a <em>simple</em> LTN12 source that produces the | 318 | The function returns a <em>simple</em> |
301 | message contents as defined by <tt>mesgt</tt>. Hopefully, the following | 319 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> |
320 | source that produces the | ||
321 | message contents as defined by <tt>mesgt</tt>, chunk by chunk. | ||
322 | Hopefully, the following | ||
302 | example will make things clear. When in doubt, refer to the appropriate RFC | 323 | example will make things clear. When in doubt, refer to the appropriate RFC |
303 | as listed in the introduction. </p> | 324 | as listed in the introduction. </p> |
304 | 325 | ||
@@ -320,7 +341,7 @@ source = smtp.message{ | |||
320 | body = { | 341 | body = { |
321 | preamble = "If your client doesn't understand attachments, \r\n" .. | 342 | preamble = "If your client doesn't understand attachments, \r\n" .. |
322 | "it will still display the preamble and the epilogue.\r\n" .. | 343 | "it will still display the preamble and the epilogue.\r\n" .. |
323 | "Preamble might show up even in a MIME enabled client.", | 344 | "Preamble will probably appear even in a MIME enabled client.", |
324 | -- first part: no headers means plain text, us-ascii. | 345 | -- first part: no headers means plain text, us-ascii. |
325 | -- The mime.eol low-level filter normalizes end-of-line markers. | 346 | -- The mime.eol low-level filter normalizes end-of-line markers. |
326 | [1] = { | 347 | [1] = { |