diff --git a/src/smtp.lua b/src/smtp.lua index d256388..c823c97 100644 --- a/src/smtp.lua +++ b/src/smtp.lua @@ -87,7 +87,7 @@ end local function sendsource(mesgt) -- set content-type if user didn't override if not mesgt.headers or not mesgt.headers["content-type"] then - coroutine.yield('content-type: text/plain; charset="iso-88591"\r\n') + coroutine.yield('content-type: text/plain; charset="iso-8859-1"\r\n') end -- finish headers coroutine.yield("\r\n") @@ -104,7 +104,7 @@ end local function sendstring(mesgt) -- set content-type if user didn't override if not mesgt.headers or not mesgt.headers["content-type"] then - coroutine.yield('content-type: text/plain; charset="iso-88591"\r\n') + coroutine.yield('content-type: text/plain; charset="iso-8859-1"\r\n') end -- finish headers coroutine.yield("\r\n") @@ -135,7 +135,7 @@ local function adjustheaders(mesgt) mesgt.headers = mesgt.headers or {} mesgt.headers["mime-version"] = "1.0" mesgt.headers["date"] = mesgt.headers["date"] or - os.date("%a, %d %b %Y %H:%M:%S") .. (mesgt.zone or ZONE) + os.date("!%a, %d %b %Y %H:%M:%S ") .. (mesgt.zone or ZONE) mesgt.headers["x-mailer"] = mesgt.headers["x-mailer"] or socket.version end diff --git a/test/testmesg.lua b/test/testmesg.lua new file mode 100644 index 0000000..228bbe4 --- /dev/null +++ b/test/testmesg.lua @@ -0,0 +1,53 @@ +mesgt = { + headers = { + to = "D Burgess ", + subject = "Looking good! (please check headers)" + }, + body = { + preamble = "Some attatched stuff", + [1] = { + body = "Testing stuffing.\r\n.\r\nGot you.\r\n.Hehehe.\r\n" + }, + [2] = { + headers = { + ["content-type"] = 'application/octet-stream; name="luasocket"', + ["content-disposition"] = 'attachment; filename="luasocket"', + ["content-transfer-encoding"] = "BASE64" + }, + body = ltn12.source.chain( + ltn12.source.file(io.open("luasocket", "rb")), + 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("message.lua", "rb")), + ltn12.filter.chain( + mime.normalize(), + mime.encode("quoted-printable"), + mime.wrap("quoted-printable") + ) + ) + }, + epilogue = "Done attaching stuff", + } +} + +-- sink = ltn12.sink.file(io.stdout) +-- source = ltn12.source.chain(socket.smtp.message(mesgt), socket.smtp.stuff()) +-- ltn12.pump(source, sink) + +print(socket.smtp.send { + rcpt = {"", ""}, + from = "", + source = socket.smtp.message(mesgt), + server = "smtp.princeton.edu" +})