-
-
Save kirubz/b01adb92c8848eda8e33773418bf05d3 to your computer and use it in GitHub Desktop.
Revisions
-
Danukeru created this gist
Apr 1, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ -- requires an SMTP server to send emails local smtp = require("socket.smtp") local ltn12 = require("ltn12") local mime = require("mime") from = "<[email protected]>" rcpt = { "<[email protected]>" } -- the multipart message definition mesgt = { headers = { to = "Bob <[email protected]>", subject = "Sending attachment over e-mail test" }, body = { -- the message content [1] = { body = "Sending you a nice file! :D" }, -- the file attachment [2] = { headers = { ["content-type"] = 'attachment; name="testfile.bin"', ["content-disposition"] = 'attachment; filename="testfile.bin"', ["content-description"] = 'test binary file', ["content-transfer-encoding"] = "BASE64" }, body = ltn12.source.chain( ltn12.source.file( io.open( "/path/to/testfile.bin", "rb")), ltn12.filter.chain( mime.encode("base64"), mime.wrap() ) ) } } } -- send the message r, e = smtp.send{ from = from, rcpt = rcpt, source = smtp.message(mesgt) }