diff options
Diffstat (limited to 'src/smtp.lua')
| -rw-r--r-- | src/smtp.lua | 7 |
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() | |||
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | function metat.__index:close() | 62 | function metat.__index:close() |
| 63 | return self.try(self.tp:close()) | 63 | return self.tp:close() |
| 64 | end | 64 | end |
| 65 | 65 | ||
| 66 | function metat.__index:login(user, password) | 66 | function metat.__index:login(user, password) |
| @@ -104,9 +104,10 @@ end | |||
| 104 | 104 | ||
| 105 | function open(server, port) | 105 | function 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 |
| 110 | end | 111 | end |
| 111 | 112 | ||
| 112 | --------------------------------------------------------------------------- | 113 | --------------------------------------------------------------------------- |
