SHOW:
|
|
- or go back to the newest paste.
| 1 | - | -- This is the server code. For the client, go to http://pastebin.com/peCQzp0E |
| 1 | + | myid = os.getComputerID() |
| 2 | - | print("Running eMail server")
|
| 2 | + | print("SMail Server " ..myid.." now online.")
|
| 3 | - | rednet.open("right")
|
| 3 | + | rednet.open("right")
|
| 4 | - | while true do |
| 4 | + | while true do |
| 5 | - | id, message = rednet.receive() |
| 5 | + | id, message = rednet.receive() |
| 6 | - | if fs.exists(id .. message) then |
| 6 | + | if message == "4CTIV3" then |
| 7 | - | mail = fs.open(id .. message, "r") |
| 7 | + | rednet.broadcast("Computer " .. id .. " connected to the BBS")
|
| 8 | - | print("Computer " .. id .. " read his mail number " .. message)
|
| 8 | + | print("Computer " .. id .. " connected to the BBS via Modem.")
|
| 9 | - | readmail = mail.readAll() |
| 9 | + | end |
| 10 | - | rednet.broadcast(readmail) |
| 10 | + | if message == "readmail" and fs.exists(id) then |
| 11 | - | mail.close() |
| 11 | + | mail = fs.open(id, "r") |
| 12 | - | fs.delete(id) |
| 12 | + | print("Computer " .. id .. " read his Mail.")
|
| 13 | - | else if message == "sendmail" then |
| 13 | + | readmail = mail.readAll() |
| 14 | - | id1, to = rednet.receive() |
| 14 | + | rednet.broadcast(readmail) |
| 15 | - | a = 1 |
| 15 | + | mail.close() |
| 16 | - | while fs.exists(to .. a) do |
| 16 | + | fs.delete(id) |
| 17 | - | a = a + 1 |
| 17 | + | end |
| 18 | - | end |
| 18 | + | if message == "sendmail" then |
| 19 | - | mail = fs.open(to .. a, "w") |
| 19 | + | id1, to = rednet.receive() |
| 20 | - | mail.writeLine("From: " .. id)
|
| 20 | + | mail = fs.open(to, "w") |
| 21 | - | mail.writeLine("To: " .. to)
|
| 21 | + | mail.writeLine("From: " .. id)
|
| 22 | - | id2, tm = rednet.receive() |
| 22 | + | mail.writeLine("To: " .. to)
|
| 23 | - | mail.write(tm) |
| 23 | + | id2, tm = rednet.receive() |
| 24 | - | mail.close() |
| 24 | + | mail.write(tm) |
| 25 | - | print("Computer " .. id .. " sent Mail to " .. to)
|
| 25 | + | mail.close() |
| 26 | - | end |
| 26 | + | print("Computer " .. id .. " sent Mail to " .. to)
|
| 27 | - | end |
| 27 | + | end |
| 28 | - | end |
| 28 | + | end |