1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2025-07-17 06:09:50 +02:00

send mail service

This commit is contained in:
Xuan Sang LE
2018-02-22 15:47:09 +01:00
parent dceca89eea
commit 68f2757c00
10 changed files with 243 additions and 31 deletions

View File

@ -1,6 +1,6 @@
BUILDDIR = ../build/info
copyfiles = index.ls style.css
copyfiles = index.ls style.css sendmail.lua
main:
- mkdir $(BUILDDIR)

20
info/sendmail.lua Normal file
View File

@ -0,0 +1,20 @@
if not REQUEST.query.json then
fail("unknown request")
end
local rq = (JSON.decodeString(REQUEST.query.json))
local to = "xsang.le@gmail.com"
local from = "From: "..rq.email.."\n"
local suject = "Subject: "..rq.subject.."\n"
local content = "Contact request from:"..rq.name.."\n Email:"..rq.email.."\n"..rq.content.."\n"
local cmd = 'echo "'..utils.escape(from..suject..content)..'"| sendmail '..to
print(cmd)
local r = os.execute(cmd)
if r then
result(r)
else
fail("Cannot send email at the moment, the service may be down")
end