From 9286b96d00eaf0d67a817d0e5d24c6b90d910b88 Mon Sep 17 00:00:00 2001 From: Izaya Date: Fri, 9 Mar 2018 19:21:24 +1100 Subject: [PATCH] added mmail-send, so you can vaguely send mmails --- MMail/OpenOS/usr/bin/mmail-send.lua | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 MMail/OpenOS/usr/bin/mmail-send.lua diff --git a/MMail/OpenOS/usr/bin/mmail-send.lua b/MMail/OpenOS/usr/bin/mmail-send.lua new file mode 100644 index 0000000..1129e19 --- /dev/null +++ b/MMail/OpenOS/usr/bin/mmail-send.lua @@ -0,0 +1,45 @@ +local net = require "net" + +local tArgs = {...} +local hostname = io.open("/etc/hostname","rb"):read() + +if not tArgs[1] then + io.write("To: ") + tArgs[1] = io.read() +end + +if not tArgs[2] then + io.write("From: ") + tArgs[2] = io.read() + print("\n") +end + +if not tArgs[3] then + io.write("Subject: ") + tArgs[3] = io.read() +end + +local user,host = tArgs[1]:match("(.+)@(.+)") +local from = tArgs[2] .. "@" .. hostname +subject = tArgs[3] + +print("To: "..user.."@"..host) +print("From: "..from) +print("Subject: "..subject) + +local fileID = tArgs[4] +if not fileID then + fileID = "/tmp/mail-"..tostring(math.random(1000000,9999999)) + os.execute("edit "..fileID) +end + +local f = io.open(fileID,"rb") +local message = f:read("*a") +f:close() + +socket = net.open(host,25) +socket:write("To: "..user.."@"..host.."\n") +socket:write("From: "..from.."\n") +socket:write("Subject: "..subject.."\n") +socket:write(message) +socket:close()