EMail Alert When Backend Server Goes Down

I’m using haproxy 2.4.22 on Ubuntu Server 22.04 and I would like to have the server send an email alert when a backend server goes down.

Here is a portion of my /etc/haproxy/haproxy.cfg file :

mailers omm_relay
mailer smtp1
mailer smtp2

email-alert mailers omm_relay
email-alert from
email-alert to
email-alert level info

When I shut down a backend server, I see this in the haproxy.log file :

haproxy[7704]: [WARNING] (7704) : Server rabbitCluster_web/web1 is DOWN, reason: Layer4 timeout, check duration: 2001ms

Despite that I do not receive any email from the server.

I have installed postfix and mailutils and used them to confirm that the server can send email though those SMTP servers with no authentication.

I don’t see any record of haproxy trying to send email at all.

I’ve also tried putting the email-alert config lines in the backend section but that doesn’t work either.

Any ideas what might be wrong or how I can further diagnose this?

Thank you.

Using port 25 instead of port 587 got alerts working for me. I’m not sure exactly why 587 didn’t work because I tested with telnet and verified that the haproxy server can connect to and use SMPT on the mail server on 587. In any case it is working for me on port 25 so I’m all set now.