Throttling outbound emails with Mailman & Exim

Many ISPs have limits on the amount of emails received in a period of time, not respecting this will reduce the reputation of the sender.

Mailman 2 doesn’t support throttling, though there’re some patches in the wild adding this feature. Exim supports rate limiting incoming emails, but not emails going out, though it may be possible to do this with some convoluted configuration.

The easy solution is to rate limit emails coming from Mailman to Exim, so Mailman will retry them later.

This is the Mailman configuration:


Here we tell Mailman to retry sending delayed emails every 15 minutes, this is the minimum possible time, because the retry process only runs every 15 minutes. The default value is 1 hour.

This is the Exim configuration:

acl_smtp_rcpt = acl_check_rcpt


  defer hosts = +relay_from_hosts
        ratelimit = 75 / 15m / per_rcpt / $domain
        message = Rate limit exceeded for $domain: \
                  $sender_rate/$sender_rate_period \
                  (max $sender_rate_limit)

Here we’re telling Exim to accept no more than 75 emails every 15 minutes for any given domain. As seen above 15 minutes is the minimum possible for Mailman. The value 75 depends on how many emails you’re sending: look at the exim logs, pick up the domain you’re sending the most emails, and adjust this value accordingly.

Backup MX for Mailman, with Exim

This week a hard disk from one of my servers broke. It has been replaced with just 3 minutes of downtime (kudos to OVH), and right now the RAID array is being rebuilt.

Since this is the first time this happens to me, and the server is running a production mailman service, I decided to take my time and set-up a backup MX server. This is how I did it.

Remember that I am using a Gentoo distribution, this may be slightly different in other distro. Continue reading “Backup MX for Mailman, with Exim”

Gentoo: How to debug Exim

If you have some problem with exim, and the logs are not enough, edit the /etc/conf.d/exim file, and add the debugging option (-d):

# Command-line options for running exim
EXIM_OPTS="-bd -q15m -d"

Then restart exim:

# /etc/init.d/exim restart

The exim daemon will not be detached from the console, the debug information will be printed to the standard output. Good luck!