Bulk Mail Relay

See #8424 for implementation details.

See the email deliverability page for information how to protect our email deliverability.

See individual mail relay for relaying individual email.

Big Picture

The over all concept is: most corporate providers allow mail through based on the ratio of delivered mail without complaints to bounced mail and complaints (complaints means people who click the "this is spam" link).

So, our strategy is to configure all of our bulk email servers to use the same dedicated servers to relay email to specific big providers, so we increase the volume of legit mail to help tip the balance when a member (inevitably) sends a bunch of bad addresses or has users click the "this is spam" button.

In other words, all email destined for AOL (for example), regardless of which server the email originates on, gets relayed to AOL via Meanwhile, can point to one IP address or, ideally, two or three (so if one IP address gets blocked, we simply turn it off and rely on the remaining two).

The benefits of this strategy are:

  • build a better reputation for any given email provider by combining all sent messages from all MF/PL servers so they originate from one, or a few, IP address
  • provide flexibility so we can easily redirect messages being blocked on one server to be redirect to a different relay server
  • permanently or temporarily rate-limit sending messages to certain providers, without affecting other providers
  • take special action on messages just before being relayed (see, for example, our technique to avoid strict DMARC rules). By maintaining servers that only relay email out, we can safely apply rules that will not affect incoming messages.


The following email list servers are currently using this system:

  • (provides both and
  • (provides and
  • (used by Rochester IMC)
  • (used by portside)
  • (used by PTP)

This strategy should also be adopted by and

We currently have two servers setup as dedicated mail relay servers (cleveland on malaka and rustin on florence). These servers run multi-postfix instances (see #6662 for more information on the setup). That means, each server has multiple instances of postfix running on different IP addresses.

We have setup special domain names for each of the main mail providers:

  • All hotmail/ is relayed via:
  • Earthlink/Mindspring/IGC, etc is relayed via:
  • AOL email is relayed via:
  • Yahoo email is relayed via:
  • Gmail:
  • Comcast:
  • Everything else goes through:

Future plans include adding:

  • (bellsouth, etc)

Each of our bulk mail servers is configured to relay email to the appropriate relay by using the transport_maps Postfix configuration parameter.

Each domain name has a 600 second time-to-live and points to one or more of the IP addresses assigned to the relay servers.

Special relay

In addition to the relays listed above which are designed for bulk email, we also have relays called "nospam." The server a different purpose. The nospam relays are for relaying email messages on behalf of our MOSH'es. MOSH'es relay the following email:

  • Forwarding email addresses. An MF/PL user can configure their email address to forward to another address, onsite or offsite.
  • Auto responder. An MF/PL user can configure an auto-response every time they receive an email message
  • Web generated email. A web site (e.g. Drupal or WordPress) often sends email, such as password reminders (or massive amounts of spam if it is compromised). NOTE: CiviCRM or web sites designed to send mass email should be specially configured to relay via

All three kinds of email have a very large spam ratio and often cause the sending server to be blocked. As a result, the nospam relay is designed to drop all email with a spamassassin score of 5 or above. Note: it should only be used to relay less important email. Our typically policy is never to discard spam and let the user have the option of reviewing it. The nospam relay is a compromise of this principle to ensure consistent deliverability.

How Do I…

Review how well email is being delivered?

Run mf-mail-stats-print on rustin and/or cleveland. Here's sample output:

0 rustin:~# mf-mail-stats-print





0 rustin:~#

Get a breakdown of which instance is filling the mailq



View the mailq for a given instance


mf-postfix-queue-report /etc/{queue-name}

Flush deferred email from one queue to another queue

If deferred email is building up in one instance (referred to below as the clogged instance), you can move it to another instance (referred to below as the target instance). For example if aol-b is deferring email (clogged), but aol-a is delivering (target), you can move all deferred email from msn-a to msn-b by following these steps. NOTE: This only works if you move the messages between instances on the same server.

  • Figure out which instance is running with which IP address:
    0 cleveland:~# ip addr | grep aol
        inet brd scope global eth0:aola
        inet brd scope global secondary eth0:aolb
    0 cleveland:~#
  • Pull all deferred messages on hold on the clogged instance:
    0 cleveland:~# postsuper -c /etc/postfix-aol-b/ -h ALL deferred
    postsuper: Placed on hold: 127 messages
    0 cleveland:~#
  • Move all held messages to the target maildrop folder
    0 cleveland:~# mv /var/spool/postfix-aol-b/hold/* /var/spool/postfix-aol-a/maildrop/
    0 cleveland:~#
  • Clean up. Deferred messages have a corresponding file in the defer queue with the reason why they were deferred. Delete these files.
    for file in $(find /var/spool/postfix-aol-b/defer -type f); do name=$(echo $file | cut -d/ -f6,7) && [  ! -f "/var/spool/postfix-aol-b/deferred/$name" ] && rm -f "$file"; done

Warm up a new IP address for a given relay instance

For example, to add a new IP address for

  • Allocate new IP address
  • Create an A record and ptr record that ties the IP address to the host name (e.g. or Set the time to live to 3600 (it's important to have along ttl since some providers do a reverse DNS lookup of the sending IP address and will punish you if the ttl is too short).
  • Add this instance to either rustin.pp or cleveland.pp. Be sure to use rate limiting when warming up a new IP address. See the yahoo relays (which are permanently rate limited) for an example of how to do it.
  • When you are sure it's configured properly, create an A record from the $ to the IP address. When adding a new IP address, you may not want a lot of email to go to it initially. Instead, you can "warm it up" by controlling the ratio of IP addresses in use for the given domain. For example, you can add give A records for the existing IP address and one A record for the new one. After month, remove one of the old A records and add a new one for the new IP address.

Configure a bulk email server to use this setup

  • Add the IP address of the bulk email server to the puppet file manifests/global.pp, to the variable $mfpl_relaying_ips.
  • Be sure to push to both cleveland and rustin and restart postfix on both servers for good measure
  • Add the following to the new server's /etc/postfix/ file:
    transport_maps = hash:/etc/postfix/transport.relay

If already has a line for transport_maps, you can add a new value following a comma, e.g.:

transport_maps = hash:/etc/postfix/transport,hash:/etc/postfix/transport.relay
  • Add the following to the server's pp file:
    m_postfix::map { "/etc/postfix/transport.relay":
     source => "puppet:///modules/mayfirst/postfix/transport.relay",
     replace => "yes"
Last modified 2 years ago Last modified on Jul 11, 2019, 3:18:58 PM