# How to send email via HAProxy

**URL:** https://discourse.haproxy.org/t/how-to-send-email-via-haproxy/3952
**Category:** Help!
**Created:** [June 21, 2019, 4:40am UTC](https://discourse.haproxy.org/t/how-to-send-email-via-haproxy/3952 "2019-06-21T04:40:29Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![ciprian.craciun](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/ciprian.craciun/32/722_2.png) [@ciprian.craciun](https://discourse.haproxy.org/u/ciprian.craciun)
#### Post date: [June 21, 2019, 6:42am UTC](https://discourse.haproxy.org/t/how-to-send-email-via-haproxy/3952/2 "2019-06-21T06:42:45Z")

</div>

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:

```auto

frontend smtp-frontend
    mode tcp
    bind ipv4@0.0.0.0:25
    bind ipv4@0.0.0.0:587
    bind ipv4@0.0.0.0:465 ssl crt /etc/ssl/private/smtp.pem verify none
    default_backend smtp-backend

backend smtp-backend
    mode tcp
    server server-1 ipv4@172.0.0.1:25 maxconn 8 send-proxy check
    server server-2 ipv4@172.0.0.2:25 maxconn 8 send-proxy check
    server server-3 ipv4@172.0.0.3:25 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/main.cf`:

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

```

---

_[View the full topic](https://discourse.haproxy.org/t/how-to-send-email-via-haproxy/3952)._
