Wenades

Email Server

Jul 18th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. print("Running eMail server")
  2. rednet.open("right")
  3. while true do
  4. id, message = rednet.receive()
  5. if message == "con" then
  6. rednet.broadcast("Computer " .. id .. " connected to the BBS")
  7. print("Computer " .. id .. " connected to the BBS via Modem.")
  8. end
  9. if message == "readmail" and fs.exists(id) then
  10. mail = fs.open(id, "r")
  11. print("Computer " .. id .. " read his Mail.")
  12. readmail = mail.readAll()
  13. rednet.broadcast(readmail)
  14. mail.close()
  15. fs.delete(id)
  16. end
  17. if message == "sendmail" then
  18. id1, to = rednet.receive()
  19. mail = fs.open(to, "w")
  20. mail.writeLine("From: " .. id)
  21. mail.writeLine("To: " .. to)
  22. id2, tm = rednet.receive()
  23. mail.write(tm)
  24. mail.close()
  25. print("Computer " .. id .. " sent Mail to " .. to)
  26. end
  27. end
Add Comment
Please, Sign In to add comment