update mail.lua
This commit is contained in:
parent
74dc85da83
commit
50aaeca4af
1 changed files with 22 additions and 1 deletions
23
mail.lua
23
mail.lua
|
@ -53,8 +53,12 @@ end
|
||||||
|
|
||||||
from = nil
|
from = nil
|
||||||
to = nil
|
to = nil
|
||||||
|
dir = nil
|
||||||
data = false
|
data = false
|
||||||
dataBuf = ""
|
dataBuf = ""
|
||||||
|
|
||||||
|
boxes = table.slice(arg,1)[1]
|
||||||
|
|
||||||
print("220 doesnm.cc Simple Mail Transfer Service Ready")
|
print("220 doesnm.cc Simple Mail Transfer Service Ready")
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
|
@ -96,7 +100,20 @@ while true do
|
||||||
else
|
else
|
||||||
if string.starts(line[2],"TO:") then
|
if string.starts(line[2],"TO:") then
|
||||||
to = table.concat(table.slice(mysplit(table.concat(line," "),":"),2))
|
to = table.concat(table.slice(mysplit(table.concat(line," "),":"),2))
|
||||||
|
|
||||||
|
boxes = table.slice(arg,1)
|
||||||
|
for i=1,#boxes do
|
||||||
|
boxes[i] = mysplit(boxes[i],":")
|
||||||
|
if to:find(boxes[i][1]) then
|
||||||
|
dir = boxes[i][2]
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if dir == nil then
|
||||||
|
print("550 mail adress not found and server don't support forwarding")
|
||||||
|
else
|
||||||
print("250 OK")
|
print("250 OK")
|
||||||
|
end
|
||||||
else
|
else
|
||||||
print("502 Unrecognized command")
|
print("502 Unrecognized command")
|
||||||
end
|
end
|
||||||
|
@ -107,10 +124,14 @@ to = table.concat(table.slice(mysplit(table.concat(line," "),":"),2))
|
||||||
elseif line[1] == "." and data == true then
|
elseif line[1] == "." and data == true then
|
||||||
if not validate(dataBuf,from,to) then print("250 NOTOK")
|
if not validate(dataBuf,from,to) then print("250 NOTOK")
|
||||||
data = false else
|
data = false else
|
||||||
out = io.open("/var/mail/root","a")
|
|
||||||
|
name = os.time() .. "." .. _G["posix.unistd"].getpid() .. "." .. os.execute("hostname")
|
||||||
|
ptf = dir .. "/tmp/" .. name
|
||||||
|
out = io.open(ptf,"w")
|
||||||
out:write("From " .. from .." ".. os.date("%a %b %d %H:%M:%S %Y") .. "\n")
|
out:write("From " .. from .." ".. os.date("%a %b %d %H:%M:%S %Y") .. "\n")
|
||||||
out:write(dataBuf)
|
out:write(dataBuf)
|
||||||
out:close()
|
out:close()
|
||||||
|
os.rename(ptf,dir .. "/new/" .. name)
|
||||||
print("250 OK")
|
print("250 OK")
|
||||||
data = false
|
data = false
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue