diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-05-25 14:24:39 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-05-25 14:24:39 +0100 |
commit | 73ce1838a266bfb021ec2c72aacd8562cad15467 (patch) | |
tree | db9478b69b82e632ce3d1428f7518964de43d620 /lualib/lua_smtp.lua | |
parent | 3372a1c17c49f397d76825e3f62496f7438991c1 (diff) | |
download | rspamd-73ce1838a266bfb021ec2c72aacd8562cad15467.tar.gz rspamd-73ce1838a266bfb021ec2c72aacd8562cad15467.zip |
[Minor] Rework API to remove task dependency
Diffstat (limited to 'lualib/lua_smtp.lua')
-rw-r--r-- | lualib/lua_smtp.lua | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lualib/lua_smtp.lua b/lualib/lua_smtp.lua index 7887eff59..c112295f7 100644 --- a/lualib/lua_smtp.lua +++ b/lualib/lua_smtp.lua @@ -15,6 +15,7 @@ limitations under the License. ]]-- local rspamd_tcp = require "rspamd_tcp" +local lua_util = require "lua_util" local exports = {} @@ -24,7 +25,7 @@ local default_timeout = 10.0 --[[[ -- @function lua_smtp.sendmail(task, message, opts, callback) --]] -local function sendmail(task, message, opts, callback) +local function sendmail(opts, message, callback) local stage = 'connect' local function mail_cb(err, data, conn) @@ -180,14 +181,12 @@ local function sendmail(task, message, opts, callback) opts.recipients = {opts.recipients} end - if not rspamd_tcp.request({ - task = task, - callback = mail_cb, - stop_pattern = CRLF, - host = opts.host, - port = opts.port or 25, - timeout = opts.timeout or default_timeout, - }) then + local tcp_opts = lua_util.shallowcopy(opts) + tcp_opts.stop_pattern = CRLF + tcp_opts.timeout = opts.timeout or default_timeout + tcp_opts.callback = mail_cb + + if not rspamd_tcp.request(tcp_opts) then callback(false, 'cannot make a TCP connection') end end |