Each array entry is a name:desc pair where desc represents the full server
address (including port) as described in haproxy's configuration file.
+.. js:attribute:: ProxyMailers.mailservers_timeout
+
+ An integer representing the maximum time in milliseconds to wait for the
+ email to be sent. See "timeout mail" directive from "mailers" section in
+ haproxy configuration file.
+
.. js:attribute:: ProxyMailers.smtp_hostname
A string containing the hostname to use for the SMTP transaction.
-- same format used in haproxy config file. It will be passed as it is to
-- tcp::connect() without explicit port argument. See Socket.connect()
-- manual for more information.
-function smtp_send_email(server, domain, from, to, data)
+--
+-- The function will abort after <timeout> ms
+function smtp_send_email(server, timeout, domain, from, to, data)
local ret
local reason
local tcp = core.tcp()
end
end
+ if timeout ~= 0 then
+ tcp:settimeout(timeout / 1000)
+ end
+
if tcp:connect(server) == nil then
return false, "Can't connect to \""..server.."\""
end
for name, mailsrv in pairs(job.mailconf.mailservers) do
-- finally, send email to server
local ret, reason = smtp_send_email(mailsrv,
+ job.mailconf.mailservers_timeout,
job.mailconf.smtp_hostname,
job.mailconf.smtp_from,
job.mailconf.smtp_to,
}
lua_settable(L, -3);
+ /* mailers timeout (from mailers section) */
+ lua_pushstring(L, "mailservers_timeout");
+ lua_pushinteger(L, px->email_alert.mailers.m->timeout.mail);
+ lua_settable(L, -3);
+
/* email-alert myhostname */
lua_pushstring(L, "smtp_hostname");
lua_pushstring(L, px->email_alert.myhostname);