diff options
Diffstat (limited to '')
-rw-r--r-- | gem/ex12.lua | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/gem/ex12.lua b/gem/ex12.lua deleted file mode 100644 index de17d76..0000000 --- a/gem/ex12.lua +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | local smtp = require"socket.smtp" | ||
2 | local mime = require"mime" | ||
3 | local ltn12 = require"ltn12" | ||
4 | |||
5 | CRLF = "\013\010" | ||
6 | |||
7 | local message = smtp.message{ | ||
8 | headers = { | ||
9 | from = "Sicrano <sicrano@example.com>", | ||
10 | to = "Fulano <fulano@example.com>", | ||
11 | subject = "A message with an attachment"}, | ||
12 | body = { | ||
13 | preamble = "Hope you can see the attachment" .. CRLF, | ||
14 | [1] = { | ||
15 | body = "Here is our logo" .. CRLF}, | ||
16 | [2] = { | ||
17 | headers = { | ||
18 | ["content-type"] = 'image/png; name="luasocket.png"', | ||
19 | ["content-disposition"] = | ||
20 | 'attachment; filename="luasocket.png"', | ||
21 | ["content-description"] = 'LuaSocket logo', | ||
22 | ["content-transfer-encoding"] = "BASE64"}, | ||
23 | body = ltn12.source.chain( | ||
24 | ltn12.source.file(io.open("luasocket.png", "rb")), | ||
25 | ltn12.filter.chain( | ||
26 | mime.encode("base64"), | ||
27 | mime.wrap()))}}} | ||
28 | |||
29 | assert(smtp.send{ | ||
30 | rcpt = "<diego@cs.princeton.edu>", | ||
31 | from = "<diego@cs.princeton.edu>", | ||
32 | server = "localhost", | ||
33 | port = 2525, | ||
34 | source = message}) | ||