How to Set Up Greylisting to Reduce Spam

Greylisting temporarily rejects mail from unfamiliar senders, exploiting the fact that legitimate mail servers retry while much spam software doesn't — a simple, effective, low-overhead spam reduction technique.

How Greylisting Works

On first contact from an unfamiliar sender/IP combination, the receiving server temporarily rejects the message with a "try again later" response — legitimate mail servers, following standard SMTP retry behavior, try again after a delay and succeed; much spam-sending software doesn't bother retrying, effectively filtering it out.

The Trade-Off: Delivery Delay

Legitimate mail experiences a delay (typically several minutes) on first contact from a new sender — subsequent mail from the same sender delivers normally without delay once the initial retry succeeds; a real but generally acceptable trade-off for the spam reduction benefit.

Installing Postgrey (Postfix Greylisting)

sudo apt install postgrey -y

Configuring Postfix to Use Postgrey

sudo nano /etc/postfix/main.cf
smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination,
    check_policy_service inet:127.0.0.1:10023

Restart Services

sudo systemctl restart postgrey postfix

Configuring the Greylisting Delay

sudo nano /etc/default/postgrey
POSTGREY_OPTS="--delay=300"

300 seconds (5 minutes) is a reasonable default — longer delays increase spam filtering effectiveness slightly but also increase legitimate mail delay.

Whitelisting Known-Good Senders (Avoiding Unnecessary Delays)

sudo nano /etc/postgrey/whitelist_clients.local
google.com
outlook.com

Add domains/IPs of major, well-known senders you don't want delayed — large legitimate providers with reliable retry behavior generally work fine with greylisting anyway, but whitelisting reduces unnecessary delay for genuinely important, frequent correspondents.

Understanding the Practical Impact

Once a sender/IP combination has successfully retried once, subsequent mail delivers without delay — the delay is genuinely only for the very first contact from any given sender, not a persistent slowdown for regular correspondents.

Combining with Other Anti-Spam Measures

See How to Configure SpamAssassin for Spam Filtering — greylisting is one layer among several; combine with content-based filtering and SPF/DKIM/DMARC validation for comprehensive spam reduction.

Monitoring Greylisting Effectiveness

sudo tail -f /var/log/mail.log | grep postgrey

Review logs to understand how much mail is being greylisted and confirm legitimate mail is successfully retrying and delivering as expected.

When Greylisting Might Not Be Appropriate

If you're in a context where any delivery delay is unacceptable (time-critical transactional email, for example), greylisting's inherent delay may not be worth the trade-off — consider whether other spam mitigation techniques might be more appropriate for that specific use case.

Common Errors

Legitimate mail consistently delayed longer than expected — some legitimate senders (particularly those using load-balanced sending infrastructure) may retry from a different IP than the original attempt, effectively resetting the greylist delay each time; whitelisting known problematic senders addresses this.

Continue Reading

Browse more articles in Email Hosting & Deliverability.

  • postgrey greylisting, reduce spam postfix, greylisting setup, postfix anti-spam
  • 0 Els usuaris han Trobat Això Útil
Ha estat útil la resposta?

Articles Relacionats

How to Set Up a VPS for Email Marketing (Complete Guide)

Running your own email marketing infrastructure on a VPS gives you full control over...

How to Configure SPF, DKIM, and DMARC (Complete Guide)

SPF, DKIM, and DMARC are the three DNS-based email authentication standards that Gmail, Outlook,...

How to Set Up Reverse DNS (PTR/rDNS) for Email Deliverability

Reverse DNS (PTR record) maps your server's IP address back to a hostname — the opposite of...

IP Warm-Up: A Safe 30-Day Schedule for New Sending IPs

Mailbox providers like Gmail and Outlook monitor sending behavior closely and treat sudden...

Best Email Marketing Software for a VPS (MailWizz, Mautic, Listmonk & More)

Choosing the right self-hosted email marketing platform affects deliverability, ease of...