luasocket/test/testmesg.lua

53 lines
1.7 KiB
Lua
Raw Normal View History

2004-05-31 01:30:00 +02:00
require("smtp")
require("mime")
2004-03-19 07:14:56 +01:00
mesgt = {
headers = {
to = "D Burgess <db@werx4.com>",
subject = "Looking good! (please check headers)"
},
body = {
preamble = "Some attatched stuff",
[1] = {
body = mime.eol(0, "Testing stuffing.\n.\nGot you.\n.Hehehe.\n")
2004-03-19 07:14:56 +01:00
},
[2] = {
headers = {
2004-05-31 01:30:00 +02:00
["content-type"] = 'application/octet-stream; name="testmesg.lua"',
["content-disposition"] = 'attachment; filename="testmesg.lua"',
2004-03-19 07:14:56 +01:00
["content-transfer-encoding"] = "BASE64"
},
body = ltn12.source.chain(
2004-05-31 01:30:00 +02:00
ltn12.source.file(io.open("testmesg.lua", "rb")),
2004-03-19 07:14:56 +01:00
ltn12.filter.chain(
mime.encode("base64"),
mime.wrap()
)
)
},
[3] = {
headers = {
["content-type"] = 'text/plain; name="testmesg.lua"',
["content-disposition"] = 'attachment; filename="testmesg.lua"',
["content-transfer-encoding"] = "QUOTED-PRINTABLE"
},
body = ltn12.source.chain(
ltn12.source.file(io.open("testmesg.lua", "rb")),
2004-03-19 07:14:56 +01:00
ltn12.filter.chain(
mime.normalize(),
mime.encode("quoted-printable"),
mime.wrap("quoted-printable")
)
)
},
epilogue = "Done attaching stuff",
}
}
print(socket.smtp.send {
rcpt = "<diego@cs.princeton.edu>",
2004-03-19 07:14:56 +01:00
from = "<diego@cs.princeton.edu>",
source = socket.smtp.message(mesgt),
2004-05-26 06:58:32 +02:00
server = "mail.cs.princeton.edu"
2004-03-19 07:14:56 +01:00
})