diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2022-03-22 19:21:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-22 21:21:58 +0300 |
commit | f97dc8489d58aef2d038288f9a8bc69f907e17bb (patch) | |
tree | 3ac503f8ed1cc44b1c16528ed80347b0a5590cc7 /doc/smtp.html | |
parent | d3434c01983de3ec40e4535f856081ad138fa198 (diff) | |
download | luasocket-f97dc8489d58aef2d038288f9a8bc69f907e17bb.tar.gz luasocket-f97dc8489d58aef2d038288f9a8bc69f907e17bb.tar.bz2 luasocket-f97dc8489d58aef2d038288f9a8bc69f907e17bb.zip |
fix(docs) fix html linter issues in the docs (#358)
Diffstat (limited to 'doc/smtp.html')
-rw-r--r-- | doc/smtp.html | 191 |
1 files changed, 96 insertions, 95 deletions
diff --git a/doc/smtp.html b/doc/smtp.html index 600ec37..787d0b1 100644 --- a/doc/smtp.html +++ b/doc/smtp.html | |||
@@ -1,11 +1,11 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
2 | "http://www.w3.org/TR/html4/strict.dtd"> | 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <meta name="description" content="LuaSocket: SMTP support"> | 6 | <meta name="description" content="LuaSocket: SMTP support"> |
7 | <meta name="keywords" content="Lua, LuaSocket, SMTP, E-Mail, MIME, Multipart, | 7 | <meta name="keywords" content="Lua, LuaSocket, SMTP, E-Mail, MIME, Multipart, |
8 | Library, Support"> | 8 | Library, Support"> |
9 | <title>LuaSocket: SMTP support</title> | 9 | <title>LuaSocket: SMTP support</title> |
10 | <link rel="stylesheet" href="reference.css" type="text/css"> | 10 | <link rel="stylesheet" href="reference.css" type="text/css"> |
11 | </head> | 11 | </head> |
@@ -14,22 +14,22 @@ Library, Support"> | |||
14 | 14 | ||
15 | <!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 15 | <!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
16 | 16 | ||
17 | <div class=header> | 17 | <div class="header"> |
18 | <hr> | 18 | <hr> |
19 | <center> | 19 | <center> |
20 | <table summary="LuaSocket logo"> | 20 | <table summary="LuaSocket logo"> |
21 | <tr><td align=center><a href="http://www.lua.org"> | 21 | <tr><td align="center"><a href="http://www.lua.org"> |
22 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> | 22 | <img width="128" height="128" border="0" alt="LuaSocket" src="luasocket.png"> |
23 | </a></td></tr> | 23 | </a></td></tr> |
24 | <tr><td align=center valign=top>Network support for the Lua language | 24 | <tr><td align="center" valign="top">Network support for the Lua language |
25 | </td></tr> | 25 | </td></tr> |
26 | </table> | 26 | </table> |
27 | <p class=bar> | 27 | <p class="bar"> |
28 | <a href="index.html">home</a> · | 28 | <a href="index.html">home</a> · |
29 | <a href="index.html#download">download</a> · | 29 | <a href="index.html#download">download</a> · |
30 | <a href="installation.html">installation</a> · | 30 | <a href="installation.html">installation</a> · |
31 | <a href="introduction.html">introduction</a> · | 31 | <a href="introduction.html">introduction</a> · |
32 | <a href="reference.html">reference</a> | 32 | <a href="reference.html">reference</a> |
33 | </p> | 33 | </p> |
34 | </center> | 34 | </center> |
35 | <hr> | 35 | <hr> |
@@ -37,14 +37,14 @@ Library, Support"> | |||
37 | 37 | ||
38 | <!-- smtp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 38 | <!-- smtp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
39 | 39 | ||
40 | <h2 id=smtp>SMTP</h2> | 40 | <h2 id="smtp">SMTP</h2> |
41 | 41 | ||
42 | <p> The <tt>smtp</tt> namespace provides functionality to send e-mail | 42 | <p> The <tt>smtp</tt> namespace provides functionality to send e-mail |
43 | messages. The high-level API consists of two functions: one to | 43 | messages. The high-level API consists of two functions: one to |
44 | define an e-mail message, and another to actually send the message. | 44 | define an e-mail message, and another to actually send the message. |
45 | Although almost all users will find that these functions provide more than | 45 | Although almost all users will find that these functions provide more than |
46 | enough functionality, the underlying implementation allows for even more | 46 | enough functionality, the underlying implementation allows for even more |
47 | control (if you bother to read the code). | 47 | control (if you bother to read the code). |
48 | </p> | 48 | </p> |
49 | 49 | ||
50 | <p>The implementation conforms to the Simple Mail Transfer Protocol, | 50 | <p>The implementation conforms to the Simple Mail Transfer Protocol, |
@@ -54,19 +54,19 @@ href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a>, | |||
54 | which governs the Internet Message Format. | 54 | which governs the Internet Message Format. |
55 | Multipart messages (those that contain attachments) are part | 55 | Multipart messages (those that contain attachments) are part |
56 | of the MIME standard, but described mainly | 56 | of the MIME standard, but described mainly |
57 | in <a href="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</a> | 57 | in <a href="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</a>.</p> |
58 | 58 | ||
59 | <p> In the description below, good understanding of <a | 59 | <p> In the description below, good understanding of <a |
60 | href="http://lua-users.org/wiki/FiltersSourcesAndSinks"> LTN012, Filters | 60 | href="http://lua-users.org/wiki/FiltersSourcesAndSinks"> LTN012, Filters |
61 | sources and sinks</a> and the <a href=mime.html>MIME</a> module is | 61 | sources and sinks</a> and the <a href="mime.html">MIME</a> module is |
62 | assumed. In fact, the SMTP module was the main reason for their | 62 | assumed. In fact, the SMTP module was the main reason for their |
63 | creation. </p> | 63 | creation. </p> |
64 | 64 | ||
65 | <p> | 65 | <p> |
66 | To obtain the <tt>smtp</tt> namespace, run: | 66 | To obtain the <tt>smtp</tt> namespace, run: |
67 | </p> | 67 | </p> |
68 | 68 | ||
69 | <pre class=example> | 69 | <pre class="example"> |
70 | -- loads the SMTP module and everything it requires | 70 | -- loads the SMTP module and everything it requires |
71 | local smtp = require("socket.smtp") | 71 | local smtp = require("socket.smtp") |
72 | </pre> | 72 | </pre> |
@@ -92,40 +92,40 @@ headers = {<br> | |||
92 | <p> | 92 | <p> |
93 | Field names are case insensitive (as specified by the standard) and all | 93 | Field names are case insensitive (as specified by the standard) and all |
94 | functions work with lowercase field names (but see | 94 | functions work with lowercase field names (but see |
95 | <a href=socket.html#headers.canonic><tt>socket.headers.canonic</tt></a>). | 95 | <a href="socket.html#headers.canonic"><tt>socket.headers.canonic</tt></a>). |
96 | Field values are left unmodified. | 96 | Field values are left unmodified. |
97 | </p> | 97 | </p> |
98 | 98 | ||
99 | <p class=note> | 99 | <p class="note"> |
100 | Note: MIME headers are independent of order. Therefore, there is no problem | 100 | Note: MIME headers are independent of order. Therefore, there is no problem |
101 | in representing them in a Lua table. | 101 | in representing them in a Lua table. |
102 | </p> | 102 | </p> |
103 | 103 | ||
104 | <p> | 104 | <p> |
105 | The following constants can be set to control the default behavior of | 105 | The following constants can be set to control the default behavior of |
106 | the SMTP module: | 106 | the SMTP module: |
107 | </p> | 107 | </p> |
108 | 108 | ||
109 | <ul> | 109 | <ul> |
110 | <li> <tt>DOMAIN</tt>: domain used to greet the server; | 110 | <li> <tt>DOMAIN</tt>: domain used to greet the server;</li> |
111 | <li> <tt>PORT</tt>: default port used for the connection; | 111 | <li> <tt>PORT</tt>: default port used for the connection;</li> |
112 | <li> <tt>SERVER</tt>: default server used for the connection; | 112 | <li> <tt>SERVER</tt>: default server used for the connection;</li> |
113 | <li> <tt>TIMEOUT</tt>: default timeout for all I/O operations; | 113 | <li> <tt>TIMEOUT</tt>: default timeout for all I/O operations;</li> |
114 | <li> <tt>ZONE</tt>: default time zone. | 114 | <li> <tt>ZONE</tt>: default time zone.</li> |
115 | </ul> | 115 | </ul> |
116 | 116 | ||
117 | <!-- message ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 117 | <!-- message ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
118 | 118 | ||
119 | <p class=name id=message> | 119 | <p class="name" id="message"> |
120 | smtp.<b>message(</b>mesgt<b>)</b> | 120 | smtp.<b>message(</b>mesgt<b>)</b> |
121 | </p> | 121 | </p> |
122 | 122 | ||
123 | <p class=description> | 123 | <p class="description"> |
124 | Returns a <em>simple</em> | 124 | Returns a <em>simple</em> |
125 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> source that sends an SMTP message body, possibly multipart (arbitrarily deep). | 125 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> source that sends an SMTP message body, possibly multipart (arbitrarily deep). |
126 | </p> | 126 | </p> |
127 | 127 | ||
128 | <p class=parameters> | 128 | <p class="parameters"> |
129 | The only parameter of the function is a table describing the message. | 129 | The only parameter of the function is a table describing the message. |
130 | <tt>Mesgt</tt> has the following form (notice the recursive structure): | 130 | <tt>Mesgt</tt> has the following form (notice the recursive structure): |
131 | </p> | 131 | </p> |
@@ -135,7 +135,7 @@ The only parameter of the function is a table describing the message. | |||
135 | <tr><td><tt> | 135 | <tr><td><tt> |
136 | mesgt = {<br> | 136 | mesgt = {<br> |
137 | headers = <i>header-table</i>,<br> | 137 | headers = <i>header-table</i>,<br> |
138 | body = <i>LTN12 source</i> or <i>string</i> or | 138 | body = <i>LTN12 source</i> or <i>string</i> or |
139 | <i>multipart-mesgt</i><br> | 139 | <i>multipart-mesgt</i><br> |
140 | }<br> | 140 | }<br> |
141 | <br> | 141 | <br> |
@@ -151,36 +151,36 @@ multipart-mesgt = {<br> | |||
151 | </table> | 151 | </table> |
152 | </blockquote> | 152 | </blockquote> |
153 | 153 | ||
154 | <p class=parameters> | 154 | <p class="parameters"> |
155 | For a simple message, all that is needed is a set of <tt>headers</tt> | 155 | For a simple message, all that is needed is a set of <tt>headers</tt> |
156 | and the <tt>body</tt>. The message <tt>body</tt> can be given as a string | 156 | and the <tt>body</tt>. The message <tt>body</tt> can be given as a string |
157 | or as a <em>simple</em> | 157 | or as a <em>simple</em> |
158 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | 158 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> |
159 | source. For multipart messages, the body is a table that | 159 | source. For multipart messages, the body is a table that |
160 | recursively defines each part as an independent message, plus an optional | 160 | recursively defines each part as an independent message, plus an optional |
161 | <tt>preamble</tt> and <tt>epilogue</tt>. | 161 | <tt>preamble</tt> and <tt>epilogue</tt>. |
162 | </p> | 162 | </p> |
163 | 163 | ||
164 | <p class=return> | 164 | <p class="return"> |
165 | The function returns a <em>simple</em> | 165 | The function returns a <em>simple</em> |
166 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | 166 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> |
167 | source that produces the | 167 | source that produces the |
168 | message contents as defined by <tt>mesgt</tt>, chunk by chunk. | 168 | message contents as defined by <tt>mesgt</tt>, chunk by chunk. |
169 | Hopefully, the following | 169 | Hopefully, the following |
170 | example will make things clear. When in doubt, refer to the appropriate RFC | 170 | example will make things clear. When in doubt, refer to the appropriate RFC |
171 | as listed in the introduction. </p> | 171 | as listed in the introduction. </p> |
172 | 172 | ||
173 | <pre class=example> | 173 | <pre class="example"> |
174 | -- load the smtp support and its friends | 174 | -- load the smtp support and its friends |
175 | local smtp = require("socket.smtp") | 175 | local smtp = require("socket.smtp") |
176 | local mime = require("mime") | 176 | local mime = require("mime") |
177 | local ltn12 = require("ltn12") | 177 | local ltn12 = require("ltn12") |
178 | 178 | ||
179 | -- creates a source to send a message with two parts. The first part is | 179 | -- creates a source to send a message with two parts. The first part is |
180 | -- plain text, the second part is a PNG image, encoded as base64. | 180 | -- plain text, the second part is a PNG image, encoded as base64. |
181 | source = smtp.message{ | 181 | source = smtp.message{ |
182 | headers = { | 182 | headers = { |
183 | -- Remember that headers are *ignored* by smtp.send. | 183 | -- Remember that headers are *ignored* by smtp.send. |
184 | from = "Sicrano de Oliveira <sicrano@example.com>", | 184 | from = "Sicrano de Oliveira <sicrano@example.com>", |
185 | to = "Fulano da Silva <fulano@example.com>", | 185 | to = "Fulano da Silva <fulano@example.com>", |
186 | subject = "Here is a message with attachments" | 186 | subject = "Here is a message with attachments" |
@@ -191,20 +191,20 @@ source = smtp.message{ | |||
191 | "Preamble will probably appear even in a MIME enabled client.", | 191 | "Preamble will probably appear even in a MIME enabled client.", |
192 | -- first part: no headers means plain text, us-ascii. | 192 | -- first part: no headers means plain text, us-ascii. |
193 | -- The mime.eol low-level filter normalizes end-of-line markers. | 193 | -- The mime.eol low-level filter normalizes end-of-line markers. |
194 | [1] = { | 194 | [1] = { |
195 | body = mime.eol(0, [[ | 195 | body = mime.eol(0, [[ |
196 | Lines in a message body should always end with CRLF. | 196 | Lines in a message body should always end with CRLF. |
197 | The smtp module will *NOT* perform translation. However, the | 197 | The smtp module will *NOT* perform translation. However, the |
198 | send function *DOES* perform SMTP stuffing, whereas the message | 198 | send function *DOES* perform SMTP stuffing, whereas the message |
199 | function does *NOT*. | 199 | function does *NOT*. |
200 | ]]) | 200 | ]]) |
201 | }, | 201 | }, |
202 | -- second part: headers describe content to be a png image, | 202 | -- second part: headers describe content to be a png image, |
203 | -- sent under the base64 transfer content encoding. | 203 | -- sent under the base64 transfer content encoding. |
204 | -- notice that nothing happens until the message is actually sent. | 204 | -- notice that nothing happens until the message is actually sent. |
205 | -- small chunks are loaded into memory right before transmission and | 205 | -- small chunks are loaded into memory right before transmission and |
206 | -- translation happens on the fly. | 206 | -- translation happens on the fly. |
207 | [2] = { | 207 | [2] = { |
208 | headers = { | 208 | headers = { |
209 | ["content-type"] = 'image/png; name="image.png"', | 209 | ["content-type"] = 'image/png; name="image.png"', |
210 | ["content-disposition"] = 'attachment; filename="image.png"', | 210 | ["content-disposition"] = 'attachment; filename="image.png"', |
@@ -234,7 +234,7 @@ r, e = smtp.send{ | |||
234 | 234 | ||
235 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 235 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
236 | 236 | ||
237 | <p class=name id=send> | 237 | <p class="name" id="send"> |
238 | smtp.<b>send{</b><br> | 238 | smtp.<b>send{</b><br> |
239 | from = <i>string</i>,<br> | 239 | from = <i>string</i>,<br> |
240 | rcpt = <i>string</i> or <i>string-table</i>,<br> | 240 | rcpt = <i>string</i> or <i>string-table</i>,<br> |
@@ -249,53 +249,53 @@ smtp.<b>send{</b><br> | |||
249 | <b>}</b> | 249 | <b>}</b> |
250 | </p> | 250 | </p> |
251 | 251 | ||
252 | <p class=description> | 252 | <p class="description"> |
253 | Sends a message to a recipient list. Since sending messages is not as | 253 | Sends a message to a recipient list. Since sending messages is not as |
254 | simple as downloading an URL from a FTP or HTTP server, this function | 254 | simple as downloading an URL from a FTP or HTTP server, this function |
255 | doesn't have a simple interface. However, see the | 255 | doesn't have a simple interface. However, see the |
256 | <a href=#message><tt>message</tt></a> source factory for | 256 | <a href="#message"><tt>message</tt></a> source factory for |
257 | a very powerful way to define the message contents. | 257 | a very powerful way to define the message contents. |
258 | </p> | 258 | </p> |
259 | 259 | ||
260 | 260 | ||
261 | <p class=parameters> | 261 | <p class="parameters"> |
262 | The sender is given by the e-mail address in the <tt>from</tt> field. | 262 | The sender is given by the e-mail address in the <tt>from</tt> field. |
263 | <tt>Rcpt</tt> is a Lua table with one entry for each recipient e-mail | 263 | <tt>Rcpt</tt> is a Lua table with one entry for each recipient e-mail |
264 | address, or a string | 264 | address, or a string |
265 | in case there is just one recipient. | 265 | in case there is just one recipient. |
266 | The contents of the message are given by a <em>simple</em> | 266 | The contents of the message are given by a <em>simple</em> |
267 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | 267 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> |
268 | <tt>source</tt>. Several arguments are optional: | 268 | <tt>source</tt>. Several arguments are optional: |
269 | </p> | 269 | </p> |
270 | <ul> | 270 | <ul> |
271 | <li> <tt>user</tt>, <tt>password</tt>: User and password for | 271 | <li> <tt>user</tt>, <tt>password</tt>: User and password for |
272 | authentication. The function will attempt LOGIN and PLAIN authentication | 272 | authentication. The function will attempt LOGIN and PLAIN authentication |
273 | methods if supported by the server (both are unsafe); | 273 | methods if supported by the server (both are unsafe);</li> |
274 | <li> <tt>server</tt>: Server to connect to. Defaults to "localhost"; | 274 | <li> <tt>server</tt>: Server to connect to. Defaults to "localhost";</li> |
275 | <li> <tt>port</tt>: Port to connect to. Defaults to 25; | 275 | <li> <tt>port</tt>: Port to connect to. Defaults to 25;</li> |
276 | <li> <tt>domain</tt>: Domain name used to greet the server; Defaults to the | 276 | <li> <tt>domain</tt>: Domain name used to greet the server; Defaults to the |
277 | local machine host name; | 277 | local machine host name;</li> |
278 | <li> <tt>step</tt>: | 278 | <li> <tt>step</tt>: |
279 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | 279 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> |
280 | pump step function used to pass data from the | 280 | pump step function used to pass data from the |
281 | source to the server. Defaults to the LTN12 <tt>pump.step</tt> function; | 281 | source to the server. Defaults to the LTN12 <tt>pump.step</tt> function;</li> |
282 | <li><tt>create</tt>: An optional function to be used instead of | 282 | <li><tt>create</tt>: An optional function to be used instead of |
283 | <a href=tcp.html#socket.tcp><tt>socket.tcp</tt></a> when the communications socket is created. | 283 | <a href="tcp.html#socket.tcp"><tt>socket.tcp</tt></a> when the communications socket is created.</li> |
284 | </ul> | 284 | </ul> |
285 | 285 | ||
286 | <p class=return> | 286 | <p class="return"> |
287 | If successful, the function returns 1. Otherwise, the function returns | 287 | If successful, the function returns 1. Otherwise, the function returns |
288 | <b><tt>nil</tt></b> followed by an error message. | 288 | <b><tt>nil</tt></b> followed by an error message. |
289 | </p> | 289 | </p> |
290 | 290 | ||
291 | <p class=note> | 291 | <p class="note"> |
292 | Note: SMTP servers can be very picky with the format of e-mail | 292 | Note: SMTP servers can be very picky with the format of e-mail |
293 | addresses. To be safe, use only addresses of the form | 293 | addresses. To be safe, use only addresses of the form |
294 | "<tt><fulano@example.com></tt>" in the <tt>from</tt> and | 294 | "<tt><fulano@example.com></tt>" in the <tt>from</tt> and |
295 | <tt>rcpt</tt> arguments to the <tt>send</tt> function. In headers, e-mail | 295 | <tt>rcpt</tt> arguments to the <tt>send</tt> function. In headers, e-mail |
296 | addresses can take whatever form you like. </p> | 296 | addresses can take whatever form you like. </p> |
297 | 297 | ||
298 | <p class=note> | 298 | <p class="note"> |
299 | Big note: There is a good deal of misconception with the use of the | 299 | Big note: There is a good deal of misconception with the use of the |
300 | destination address field headers, i.e., the '<tt>To</tt>', '<tt>Cc</tt>', | 300 | destination address field headers, i.e., the '<tt>To</tt>', '<tt>Cc</tt>', |
301 | and, more importantly, the '<tt>Bcc</tt>' headers. Do <em>not</em> add a | 301 | and, more importantly, the '<tt>Bcc</tt>' headers. Do <em>not</em> add a |
@@ -303,68 +303,69 @@ and, more importantly, the '<tt>Bcc</tt>' headers. Do <em>not</em> add a | |||
303 | exact opposite of what you expect. | 303 | exact opposite of what you expect. |
304 | </p> | 304 | </p> |
305 | 305 | ||
306 | <p class=note> | 306 | <p class="note"> |
307 | Only recipients specified in the <tt>rcpt</tt> list will receive a copy of the | 307 | Only recipients specified in the <tt>rcpt</tt> list will receive a copy of the |
308 | message. Each recipient of an SMTP mail message receives a copy of the | 308 | message. Each recipient of an SMTP mail message receives a copy of the |
309 | message body along with the headers, and nothing more. The headers | 309 | message body along with the headers, and nothing more. The headers |
310 | <em>are</em> part of the message and should be produced by the | 310 | <em>are</em> part of the message and should be produced by the |
311 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | 311 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> |
312 | <tt>source</tt> function. The <tt>rcpt</tt> list is <em>not</em> | 312 | <tt>source</tt> function. The <tt>rcpt</tt> list is <em>not</em> |
313 | part of the message and will not be sent to anyone. | 313 | part of the message and will not be sent to anyone. |
314 | </p> | 314 | </p> |
315 | 315 | ||
316 | <p class=note> | 316 | <p class="note"> |
317 | <a href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a> | 317 | <a href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a> |
318 | has two <em>important and short</em> sections, "3.6.3. Destination address | 318 | has two <em>important and short</em> sections, "3.6.3. Destination address |
319 | fields" and "5. Security considerations", explaining the proper | 319 | fields" and "5. Security considerations", explaining the proper |
320 | use of these headers. Here is a summary of what it says: | 320 | use of these headers. Here is a summary of what it says: |
321 | </p> | 321 | </p> |
322 | 322 | ||
323 | <ul> | 323 | <ul> |
324 | <li> <tt>To</tt>: contains the address(es) of the primary recipient(s) | 324 | <li> <tt>To</tt>: contains the address(es) of the primary recipient(s) |
325 | of the message; | 325 | of the message;</li> |
326 | <li> <tt>Cc</tt>: (where the "Cc" means "Carbon Copy" in the sense of | 326 | <li> <tt>Cc</tt>: (where the "Cc" means "Carbon Copy" in the sense of |
327 | making a copy on a typewriter using carbon paper) contains the | 327 | making a copy on a typewriter using carbon paper) contains the |
328 | addresses of others who are to receive the message, though the | 328 | addresses of others who are to receive the message, though the |
329 | content of the message may not be directed at them; | 329 | content of the message may not be directed at them;</li> |
330 | <li> <tt>Bcc</tt>: (where the "Bcc" means "Blind Carbon | 330 | <li> <tt>Bcc</tt>: (where the "Bcc" means "Blind Carbon |
331 | Copy") contains addresses of recipients of the message whose addresses are not to be revealed to other recipients of the message. | 331 | Copy") contains addresses of recipients of the message whose addresses are not |
332 | </ul> | 332 | to be revealed to other recipients of the message.</li> |
333 | </ul> | ||
333 | 334 | ||
334 | <p class=note> | 335 | <p class="note"> |
335 | The LuaSocket <tt>send</tt> function does not care or interpret the | 336 | The LuaSocket <tt>send</tt> function does not care or interpret the |
336 | headers you send, but it gives you full control over what is sent and | 337 | headers you send, but it gives you full control over what is sent and |
337 | to whom it is sent: | 338 | to whom it is sent: |
338 | </p> | 339 | </p> |
339 | <ul> | 340 | <ul> |
340 | <li> If someone is to receive the message, the e-mail address <em>has</em> | 341 | <li> If someone is to receive the message, the e-mail address <em>has</em> |
341 | to be in the recipient list. This is the only parameter that controls who | 342 | to be in the recipient list. This is the only parameter that controls who |
342 | gets a copy of the message; | 343 | gets a copy of the message;</li> |
343 | <li> If there are multiple recipients, none of them will automatically | 344 | <li> If there are multiple recipients, none of them will automatically |
344 | know that someone else got that message. That is, the default behavior is | 345 | know that someone else got that message. That is, the default behavior is |
345 | similar to the <tt>Bcc</tt> field of popular e-mail clients; | 346 | similar to the <tt>Bcc</tt> field of popular e-mail clients;</li> |
346 | <li> It is up to you to add the <tt>To</tt> header with the list of primary | 347 | <li> It is up to you to add the <tt>To</tt> header with the list of primary |
347 | recipients so that other recipients can see it; | 348 | recipients so that other recipients can see it;</li> |
348 | <li> It is also up to you to add the <tt>Cc</tt> header with the | 349 | <li> It is also up to you to add the <tt>Cc</tt> header with the |
349 | list of additional recipients so that everyone else sees it; | 350 | list of additional recipients so that everyone else sees it;</li> |
350 | <li> Adding a header <tt>Bcc</tt> is nonsense, unless it is | 351 | <li> Adding a header <tt>Bcc</tt> is nonsense, unless it is |
351 | empty. Otherwise, everyone receiving the message will see it and that is | 352 | empty. Otherwise, everyone receiving the message will see it and that is |
352 | exactly what you <em>don't</em> want to happen! | 353 | exactly what you <em>don't</em> want to happen!</li> |
353 | </ul> | 354 | </ul> |
354 | 355 | ||
355 | <p class=note> | 356 | <p class="note"> |
356 | I hope this clarifies the issue. Otherwise, please refer to | 357 | I hope this clarifies the issue. Otherwise, please refer to |
357 | <a href="http://www.ietf.org/rfc/rfc2821.txt">RFC 2821</a> | 358 | <a href="http://www.ietf.org/rfc/rfc2821.txt">RFC 2821</a> |
358 | and | 359 | and |
359 | <a href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a>. | 360 | <a href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a>. |
360 | </p> | 361 | </p> |
361 | 362 | ||
362 | <pre class=example> | 363 | <pre class="example"> |
363 | -- load the smtp support | 364 | -- load the smtp support |
364 | local smtp = require("socket.smtp") | 365 | local smtp = require("socket.smtp") |
365 | 366 | ||
366 | -- Connects to server "localhost" and sends a message to users | 367 | -- Connects to server "localhost" and sends a message to users |
367 | -- "fulano@example.com", "beltrano@example.com", | 368 | -- "fulano@example.com", "beltrano@example.com", |
368 | -- and "sicrano@example.com". | 369 | -- and "sicrano@example.com". |
369 | -- Note that "fulano" is the primary recipient, "beltrano" receives a | 370 | -- Note that "fulano" is the primary recipient, "beltrano" receives a |
370 | -- carbon copy and neither of them knows that "sicrano" received a blind | 371 | -- carbon copy and neither of them knows that "sicrano" received a blind |
@@ -388,17 +389,17 @@ mesgt = { | |||
388 | 389 | ||
389 | r, e = smtp.send{ | 390 | r, e = smtp.send{ |
390 | from = from, | 391 | from = from, |
391 | rcpt = rcpt, | 392 | rcpt = rcpt, |
392 | source = smtp.message(mesgt) | 393 | source = smtp.message(mesgt) |
393 | } | 394 | } |
394 | </pre> | 395 | </pre> |
395 | 396 | ||
396 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 397 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
397 | 398 | ||
398 | <div class=footer> | 399 | <div class="footer"> |
399 | <hr> | 400 | <hr> |
400 | <center> | 401 | <center> |
401 | <p class=bar> | 402 | <p class="bar"> |
402 | <a href="index.html">home</a> · | 403 | <a href="index.html">home</a> · |
403 | <a href="index.html#down">download</a> · | 404 | <a href="index.html#down">download</a> · |
404 | <a href="installation.html">installation</a> · | 405 | <a href="installation.html">installation</a> · |