Mercurial Hosting > luan
comparison website/src/examples/upload-and-email.html.luan @ 1589:0c46edec25dd
mail work
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sat, 13 Mar 2021 21:02:38 -0700 |
| parents | 13135e289b50 |
| children | 92860f763715 |
comparison
equal
deleted
inserted
replaced
| 1588:0b904d30721f | 1589:0c46edec25dd |
|---|---|
| 1 local Io = require "luan:Io.luan" | 1 local Io = require "luan:Io.luan" |
| 2 local Http = require "luan:http/Http.luan" | 2 local Http = require "luan:http/Http.luan" |
| 3 local Mail = require "luan:mail/Mail.luan" | 3 local Mail = require "luan:mail/Mail.luan" |
| 4 | 4 |
| 5 | 5 |
| 6 local send = Mail.Sender{ | 6 local send = Mail.sender{ |
| 7 host = "smtpcorp.com" | 7 host = "smtpcorp.com" |
| 8 username = "smtp@luan.software" | 8 username = "smtp@luan.software" |
| 9 password = "luanhost" | 9 password = "luanhost" |
| 10 port = 2525 | 10 port = 2525 |
| 11 }.send | 11 }.send |
| 44 if email == nil then | 44 if email == nil then |
| 45 form() | 45 form() |
| 46 else | 46 else |
| 47 local file = Http.request.parameters.file | 47 local file = Http.request.parameters.file |
| 48 send{ | 48 send{ |
| 49 from = "smtp@luan.software" | 49 From = "smtp@luan.software" |
| 50 to = email | 50 To = email |
| 51 subject = "Upload and Email" | 51 Subject = "Upload and Email" |
| 52 body = "file should be attached" | 52 body = { |
| 53 attachments = {file} | 53 { |
| 54 body = "file should be attached" | |
| 55 } | |
| 56 { | |
| 57 ["Content-Type"] = file.content_type | |
| 58 ["Content-Disposition"] = [[attachment; filename="]]..file.filename..[["]] | |
| 59 body = file.content | |
| 60 } | |
| 61 } | |
| 54 } | 62 } |
| 55 sent() | 63 sent() |
| 56 end | 64 end |
| 57 end | 65 end |
