How to send email via HAProxy

I’m not quite sure what you are trying to achieve here…

Do you want to load-balance the three mail servers? (I would assume so in the rest of my reply.)

Basically you just need to define a TCP fronted and backend (with three servers), like so:

frontend smtp-frontend
    mode tcp
    bind ipv4@
    bind ipv4@
    bind ipv4@ ssl crt /etc/ssl/private/smtp.pem verify none
    default_backend smtp-backend

backend smtp-backend
    mode tcp
    server server-1 ipv4@ maxconn 8 send-proxy check
    server server-2 ipv4@ maxconn 8 send-proxy check
    server server-3 ipv4@ maxconn 8 send-proxy check

Please note the send-proxy option to server, which sends the PROXY header with the original IP of the client. To make this work in PostFix you need set the following in /etc/postfix/

smtpd_upstream_proxy_protocol = haproxy
proxy_interfaces = # the "public" IP of HAProxy, not sure if this line is actually needed