aboutsummaryrefslogtreecommitdiff
path: root/doc/smtp.html
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-16 20:41:03 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-16 20:41:03 +0000
commitba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc (patch)
tree1a49ac4a3c74b9d3bf8e4220d4bf9c48641f3dbc /doc/smtp.html
parent0a4c1534f39511894728da193ab8225ad6022de9 (diff)
downloadluasocket-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.html77
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
39messages. The implementation conforms to the Simple Mail Transfer Protocol, 39messages. The high-level API consists of two functions: one to
40define an e-mail message, and another to actually send the message.
41Although almost all users will find that these functions provide more than
42enough functionality, the underlying implementation allows for even more
43control (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>.
41Another RFC of interest is <a 48Another RFC of interest is <a
42href="http://www.cs.princeton.edu/~diego/rfc/rfc2822.txt">RFC 2822</a>, 49href="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
52assumed. In fact, the SMTP module was the main reason for their 59assumed. In fact, the SMTP module was the main reason for their
53creation. </p> 60creation. </p>
54 61
62<p>
63To obtain the <tt>smtp</tt> namespace, run:
64</p>
65
66<pre class=example>
67-- loads the SMTP module and everything it requires
68local smtp = require("smtp")
69</pre>
70
55<p> 71<p>
56MIME headers are represented as a Lua table in the form: 72MIME 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:
62headers = {<br> 78headers = {<br>
63&nbsp;&nbsp;field-1-name = <i>field-1-value</i>,<br> 79&nbsp;&nbsp;field-1-name = <i>field-1-value</i>,<br>
64&nbsp;&nbsp;field-2-name = <i>field-2-value</i>,<br> 80&nbsp;&nbsp;field-2-name = <i>field-2-value</i>,<br>
65&nbsp;&nbsp;field-3-name = <i>field-3-value</i>, 81&nbsp;&nbsp;field-3-name = <i>field-3-value</i>,<br>
66</tt></td></tr> 82&nbsp;&nbsp;...<br>
67<tr><td align=center><tt>
68&nbsp;&nbsp;...
69</tt></td></tr>
70<tr><td><tt>
71&nbsp;&nbsp;field-n-name = <i>field-n-value</i><br> 83&nbsp;&nbsp;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&nbsp;&nbsp;from = <i>string</i>,<br> 117&nbsp;&nbsp;from = <i>string</i>,<br>
106&nbsp;&nbsp;rcpt = <i>string</i> or <i>string-table</i>,<br> 118&nbsp;&nbsp;rcpt = <i>string</i> or <i>string-table</i>,<br>
107&nbsp;&nbsp;source = <i>LTN12 source</i>,<br> 119&nbsp;&nbsp;source = <i>LTN12 source</i>,<br>
108&nbsp;&nbsp;[user = <i>string</i>],<br> 120&nbsp;&nbsp;[user = <i>string</i>,]<br>
109&nbsp;&nbsp;[password = <i>string</i>],<br> 121&nbsp;&nbsp;[password = <i>string</i>,]<br>
110&nbsp;&nbsp;[server = <i>string</i>],<br> 122&nbsp;&nbsp;[server = <i>string</i>,]<br>
111&nbsp;&nbsp;[port = <i>string</i>]<br> 123&nbsp;&nbsp;[port = <i>string</i>,]<br>
112&nbsp;&nbsp;[domain = <i>string</i>],<br> 124&nbsp;&nbsp;[domain = <i>string</i>,]<br>
113&nbsp;&nbsp;[step = <i>LTN12 pump step</i>],<br> 125&nbsp;&nbsp;[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
128address, or a string 140address, or a string
129in case there is just one recipient. 141in case there is just one recipient.
130The contents of the message are given by a <em>simple</em> LTN12 <tt>source</tt>. Several 142The contents of the message are given by a <em>simple</em>
131arguments 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
140local machine host name; 153local 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>
156pump step function used to pass data from the
142source to the server. Defaults to the LTN12 <tt>pump.step</tt> function. 157source 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.
166Only recipients specified in the <tt>rcpt</tt> list will receive a copy of the 181Only recipients specified in the <tt>rcpt</tt> list will receive a copy of the
167message. Each recipient of an SMTP mail message receives a copy of the 182message. Each recipient of an SMTP mail message receives a copy of the
168message body along with the headers, and nothing more. The headers 183message 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>
171part of the message and will not be sent to anyone. 187part 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>
261Returns a LTN12 source that sends an SMTP message body, possibly multipart 277Returns 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&nbsp;<br> 294&nbsp;<br>
279multipart-mesgt = {<br> 295multipart-mesgt = {<br>
280&nbsp;&nbsp;preamble = <i>string</i><br> 296&nbsp;&nbsp;[preamble = <i>string</i>,]<br>
281&nbsp;&nbsp;[1] = <i>mesgt</i>,<br> 297&nbsp;&nbsp;[1] = <i>mesgt</i>,<br>
282&nbsp;&nbsp;[2] = <i>mesgt</i>,<br> 298&nbsp;&nbsp;[2] = <i>mesgt</i>,<br>
283&nbsp;&nbsp;...<br> 299&nbsp;&nbsp;...<br>
284&nbsp;&nbsp;[<i>n</i>] = <i>mesgt</i>,<br> 300&nbsp;&nbsp;[<i>n</i>] = <i>mesgt</i>,<br>
285&nbsp;&nbsp;epilogue = <i>string</i>,<br> 301&nbsp;&nbsp;[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>
292For a simple message, all that is needed is a set of <tt>headers</tt> 308For a simple message, all that is needed is a set of <tt>headers</tt>
293and the <tt>body</tt>. The message <tt>body</tt> can be given as a string 309and the <tt>body</tt>. The message <tt>body</tt> can be given as a string
294or as a LTN12 source. For multipart messages, the body is a table that 310or as a <em>simple</em>
295recursively defines each part as an independent message, plus a preamble 311<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
296and an epilogue. 312source. For multipart messages, the body is a table that
313recursively 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>
300The function returns a <em>simple</em> LTN12 source that produces the 318The function returns a <em>simple</em>
301message contents as defined by <tt>mesgt</tt>. Hopefully, the following 319<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
320source that produces the
321message contents as defined by <tt>mesgt</tt>, chunk by chunk.
322Hopefully, the following
302example will make things clear. When in doubt, refer to the appropriate RFC 323example will make things clear. When in doubt, refer to the appropriate RFC
303as listed in the introduction. </p> 324as 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] = {