Mass emailing solution

This setup I've created for one of my client over 4 years ago. The task was - optimize mail delivery. There are number of software packages doing legitimate mailing with lists of addresses. Traffic is about 20Gb of mails per day. Most of 5 servers where 99% CPU busy with load average of 10-20.

# Solution

Solution comes in two parts. First part is setup for mass emailing which includes 99% of mails. Second part is important emaling, which includes imortant letter like registration, account confirmation, information etc.

Mass mail setup

Balancer was used to balance load amoung all mailing servers.

Important messaging

Important messaging was split from mass mailing from the beginning to better control these emails. Separate server was setup for them to react quicker in case of problems in delivery.

Bounce message with user_id

When dealing with mass mailing proper handling of bouce messages (5XX) code is a must. Two scheme were setup to ensure no or less bounces are generated.
  1. Emaling is done with Reply-To address equal to <bounce-<user_id>@domain.tld>. This way bounsed messages are collected in mailbox and bouncing users (defined by user_id) are excluded from mailing.

Bounce messages with delivery logs

More sophisticated scheme is to combine all postfix mailing logs on one server and do analisys of delivery codes.

Bouncing addresses are temporary added to black list depedning on reponse code (4xx, 5xx). Black list is like a cache with expire field. This black list is propogated back to postfix servers for immidiate filtering.

Custom postfix setup

Postfix was optimizes for huge load. Postfix queue parameters was optimized for optimimal performance.

# Monitoring

Wihout proper monitoring it is very difficuilt to  identify problems when running. Once solution was done, I setup visual monitoring of all sending nodes with Cacti.  It displayed queue length and other postfix paramers on graphics.