Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to loadbalance outbound emails via multiple IPs, is there any built-in tool or some easy way to do it with postfix, sendmail or exim? for example if I assign three IPs to the email server and emails are sent via all the ips one by one.

share|improve this question
up vote 2 down vote accepted

If you want send mails from different Ip's from a single mail server than you should think about postfix multiple instance on a single host. And you can assign a different Ip address for each instance and your null instance will submit mails for each instance. for more detail you may refer these links This one for how to assign Ip and all and this for all basic information how we create and how instance works

share|improve this answer
the references are good, actually I am using that technique so we can setup bulk email server and do not get blocked our IP. is this some good solution you think? – Toqeer Sep 11 '12 at 5:41
If you want to prevent your Ip from blacklisting than you should use subscribed mailling lists and if you want to hide your Ip than you are categorised as spamer. – user128296 Sep 11 '12 at 6:06
one or other way our users are subscribed to the list but that are huge in numbers so I am just scared that our IP does not block, what about mailchimp, if some of their clients send emails which are unsolicted would their IPs get blocked? what mechanism they use to send emails? – Toqeer Sep 11 '12 at 8:49
you should go mailchimp terms and conditions. they block the user if user sends mail more than one mail per 1000 as spam. – user128296 Sep 11 '12 at 9:21

With Postfix 2.7 or later it's pretty easy.

First create one entry for each IP in, like this:

out1  unix -       -       n       -       -       smtp
      -o syslog_name=postfix-out1
      -o smtp_helo_name=out1.yourdomain.tld
      -o smtp_bind_address=a.b.c.1
out2  unix -       -       n       -       -       smtp
      -o syslog_name=postfix-out2
      -o smtp_helo_name=out2.yourdomain.tld
      -o smtp_bind_address=a.b.c.2
outN  unix -       -       n       -       -       smtp
      -o syslog_name=postfix-outN
      -o smtp_helo_name=outN.yourdomain.tld
      -o smtp_bind_address=a.b.c.N

Then create a sender dependent transport map in, like this:

sender_dependent_default_transport_maps = mysql:/etc/postfix/config/

Comment out all the other transport_maps in, like this:

#transport_maps = ...

Now here is the trick, this transport table will be using RAND() to randomize usage of all the out[1..n] transports listed in

In /etc/postfix/config/ write:

user = dbuser
password = dbpass
dbname = dbname
hosts = dbhost
query = SELECT transport FROM transport_roundrobin ORDER BY RAND() LIMIT 1

Finally, create a table called 'transport_roundrobin' on db 'dbname' running on 'dbhost' and insert one row for each transport:

CREATE TABLE transport_roundrobin (transport varchar(40) not null)
INSERT INTO transport_roundrobin (transport) VALUES ('out1');
INSERT INTO transport_roundrobin (transport) VALUES ('out2');
INSERT INTO transport_roundrobin (transport) VALUES ('outN');

Postfix will select a random row from the transport_roundrobin mysql table and then use the value obtained to select the corresponding transport in Each transport will use a different ip address, according to -o smtp_bind_address

share|improve this answer
can this be done somehow without mysql? – Nick May 31 at 16:08
AFAIK NO, you'd need to patch postfix – Luca G. May 31 at 16:12
is very helpful in all cases. those techniques are often used for spam and nobody usually comment them. – Nick Jun 1 at 9:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.