Mercurial Hosting > luan
view website/src/examples/upload-and-email.html.luan @ 1825:4eb0551323b0
remove initThreadLogging from LuanDomainHandler
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 21 Aug 2024 19:44:17 -0600 |
parents | 92860f763715 |
children | 50e570b598b2 |
line wrap: on
line source
local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Mail = require "luan:mail/Mail.luan" local send = Mail.sender{ host = "smtpcorp.com" username = "luan" password = "luanhost2" port = 2525 }.send local function form() %> <!doctype html> <html> <body> <h1>Upload and Email</h1> <form method="post" enctype="multipart/form-data"> <p>Email: <input name=email></p> <p><input type=file name=file></p> <p><input type=submit></p> </form> </body> </html> <% end local function sent() %> <!doctype html> <html> <body> <h1>Upload and Email</h1> <p>file sent</p> </body> </html> <% end return function() Io.stdout = Http.response.text_writer() local email = Http.request.parameters.email if email == nil then form() else local file = Http.request.parameters.file send{ From = "smtp@luan.software" To = email Subject = "Upload and Email" body = { { body = "file should be attached" } { ["Content-Type"] = file.content_type ["Content-Disposition"] = [[attachment; filename="]]..file.filename..[["]] body = file.content } } } sent() end end