aboutsummaryrefslogtreecommitdiff
path: root/src/smtp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/smtp.lua')
-rw-r--r--src/smtp.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/smtp.lua b/src/smtp.lua
index d6357d2..70b511c 100644
--- a/src/smtp.lua
+++ b/src/smtp.lua
@@ -60,7 +60,7 @@ function metat.__index:quit()
60end 60end
61 61
62function metat.__index:close() 62function metat.__index:close()
63 return self.try(self.tp:close()) 63 return self.tp:close()
64end 64end
65 65
66function metat.__index:login(user, password) 66function metat.__index:login(user, password)
@@ -104,9 +104,10 @@ end
104 104
105function open(server, port) 105function open(server, port)
106 local tp = socket.try(tp.connect(server or SERVER, port or PORT, TIMEOUT)) 106 local tp = socket.try(tp.connect(server or SERVER, port or PORT, TIMEOUT))
107 local s = setmetatable({tp = tp}, metat)
107 -- make sure tp is closed if we get an exception 108 -- make sure tp is closed if we get an exception
108 local try = socket.newtry(function() tp:close() end) 109 local try = socket.newtry(function() s:close() end)
109 return setmetatable({ tp = tp, try = try}, metat) 110 return s
110end 111end
111 112
112--------------------------------------------------------------------------- 113---------------------------------------------------------------------------