Skip to content

Instantly share code, notes, and snippets.

Last active July 18, 2023 20:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
How to Create Powerful, Customized Lua Mailers in HAProxy
lua-load /path/to/file/mailers.lua
mailers smtp_servers
mailer mailserver1
lua-load /path/to/file/mailers.lua
mailers mymailers
mailer smtp1
mailer smtp2
backend myback
email-alert mailers mymailers
email-alert from
email-alert to
# add your own monitored backend server entries below
-- prepare email body
c:add(string.format("From: %s\r\n", job.mailconf.smtp_from))
c:add(string.format("To: %s\r\n", job.mailconf.smtp_to))
c:add(string.format("Date: %s\r\n", date))
c:add(string.format("Subject: [HAProxy Alert] %s\r\n", job.msg))
c:add(string.format("%s\r\n", job.msg))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment