• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Michele Neylon :: Pensieri

Michele Neylon :: Pensieri

Technology, Marketing, Domains, Thoughts

Postgrey – Greylisting In Postfix on Ubuntu (Debian)

October 7, 2005 by Michele Neylon 5 Comments

A lot of mail server admins have been forced to implement some form of spam checks at the SMTP level.
Some of the implementations are quite demented and probably do more harm than good, whereas others are extremely sane.



Greylisting, however, seems to be a very good idea.
Basically the concept is based on spammers’ idiocy or lack of patience (take your pick). Most spammers use bruteforce methods to send as much mail at one time. Delivery rates don’t really matter. If you think about the number of viagra ads they’ve got to send out at one time you can see why that would be the case
A properly configured mailserver, however, “cares” if mail is delivered or not and so will keep retrying (up to a certain limit and depending on the SMTP response).
A mail server using greylisting will basically tell servers sending mail to it to go away for X seconds before allowing them to resend the mail and actually accepting it.
An example SMTP transaction with greylisting enabled:

Oct 7 00:24:47 sicilia postfix/smtpd[15309]: connect from xxx.blacknight.ie[217.xxx.xxx.xx]
Oct 7 00:24:47 sicilia postfix/smtpd[15309]: NOQUEUE: reject: RCPT from xx.blacknight.ie[217.xxx.xxx.xx]: 450 : Client host rejected: Greylisted for 300 seconds (see http://isg.ee.ethz.ch/tools/postgrey/help); from= to= proto=ESMTP helo=
Oct 7 00:24:47 sicilia postfix/smtpd[15309]: disconnect from xx.blacknight.ie[217.xxx.xxx.xx]

300 seconds later the sending mail server can try again and the mail will be accepted.
If the sender were a spammer they probably wouldn’t retry.
Getting this working on Ubuntu with postfix is very easy:
apt-get install postgrey
This installs the greylisting daemon for postfix and starts it.
You should be able to see that it is running with the following command:
netstat -anp | grep 60000
It should return something like:

tcp 0 0 127.0.0.1:60000 0.0.0.0:* LISTEN 14321/postgrey.pid

The final step of the configuration is to add a couple of lines to postfix’s main.cf:
smtpd_recipient_restrictions =
reject_unauth_destination
check_policy_service inet:127.0.0.1:60000

Don’t forget to reload postfix:
/etc/init.d/postfix reload
You can whitelist your own network or any trusted mail servers by editing /etc/postgrey/whitelist_clients
This seems to work for me, but your mileage may vary
The Book of Postfix

Related Posts:

  • distance-traveled
    The Irish Postal Service Failed Me!
  • Video thumbnail for youtube video 8s0fdjfbj8o
    Public Speaking Hacked
  • 289887236_594150668736944_8594055335696493546_n
    Growing my own Salad Ingredients
  • Photo of old hand written letters on a desk with some pencils and pens
    I Sometimes Yearn For Simpler Times
  • Video thumbnail for youtube video xtrb4tvjxz8
    Excellent Impressions While Singing
  • ACDC-Dublin-Ticketmaster-Q
    The "Joys" of Acquiring Concert Tickets

Filed Under: Debian, Linux, Open Source, Spam Filtering, Techie :: Techno ::, Ubuntu

Michele is founder and CEO of Irish hosting provider and domain name registrar Blacknight. Read More…

Reader Interactions

Comments

  1. Casey Woods says

    November 5, 2005 at 10:08 pm

    I’d been reading about greylisting, and your article gave me the push that I needed. I installed postgrey on my main web server and I’m amazed at how effective it is. The server load is much lower now, because Spamassassin barely has any work to do. The amount of Spam that actually makes it to the Spam filter is at least 90% lower than it used to be.

  2. blacknight says

    November 6, 2005 at 1:43 am

    Greylisting is useful, but you have to be very careful with setting up your whitelist or you could end up delaying legitimate mail too much

  3. A.Gurcan OZTURK says

    April 10, 2007 at 8:40 am

    You forgot ‘=’ in check_policy_service directive. Replace line,
    check_policy_service inet:127.0.0.1:60000
    with
    check_policy_service = inet:127.0.0.1:60000

  4. Derek says

    June 1, 2007 at 4:04 pm

    Actually, he didn’t forget the =. He forgot the comma between reject_unauth_destination and check_policy_service.

  5. Greg says

    August 1, 2007 at 7:43 am

    Derek and A.Gurcan: neither are necessary. No comma is needed because main.cf accepts indented multi-line configurations.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

dotblog founder

Mastodon

Archives

  • Bluesky
  • Instagram
  • Threads
  • Twitter

Pages

  • About Me
  • About This Site
  • Archives
  • Comments Policy
  • Contact Me
  • Newsletter
  • Privacy

Blogroll

  • Stewart Curry
  • Technology.ie Podcast
  • Gianni Ponzi
  • My Mastodon
  • Paul Savage – BlackDog SEO

Stalking Links

Subscribe to Michele Neylon :: Pensieri

Blogroll

  • Blacknight Blog
  • Damien Mulley
  • Gianni Ponzi
  • Gordon Hudson
  • Grandad
  • My Mastodon
  • Paul Savage – BlackDog SEO
  • Stewart Curry
  • Technology.ie Podcast
  • Tom Doyle

Sites

  • Business Travel Tips
  • Discount Coupon Codes
  • Domain News
  • Fat.ie – my diet blog
  • Film Posters
  • Film Reviews
  • Films
  • Free Desktop Wallpapers
  • Irish Blogger Discussion Forum
  • Irish Stamps
  • Movie Trailers and News
  • Paste.ie

Footer

Site hosted in Ireland by Blacknight - Content copyright Michele Neylon

Copyright © 2025 · Magazine Pro on Genesis Framework · WordPress · Log in