I coded a email system for my server for fun but I cant figure out why i keep getting this issue. also I only get this error when I read an email not when I send it out to the server
server:11: Expected string
print("Running eMail server")
rednet.open("right")
while true do
id, message = rednet.receive()
if fs.exists(id .. message) then
mail = fs.open(id .. message, "r")
print("Computer " .. id .. " read his mail number " .. message)
readmail = mail.readAll()
rednet.broadcast(readmail)
mail.close()
fs.delete(id)
else if message == "sendmail" then
id1, to = rednet.receive()
a = 1
while fs.exists(to .. a) do
a = a + 1
end
mail = fs.open(to .. a, "w")
mail.writeLine("Total Amount of Emails: " .. a)
if id == 1 then
mail.writeLine("From: ArestheBloodGod")
elseif id == 2 then
mail.writeLine("From: Knightofe2")
else
mail.writeLine("From: " .. id)
end
if to == "1" then
mail.writeLine("To: ArestheBloodGod")
elseif to == "2" then
mail.writeLine("To: Knightofe2")
else
mail.writeLine("To: " .. to)
end
id2, tm = rednet.receive()
mail.write
mail.close()
print("Computer " .. id .. " sent Mail to " .. to)
end
end
end
p.s. I do not take credit for this code I edited it from someone else