Enabling greylisting with directadmin using postgrey

You should download yumdownloader postgrey the you should extract this rpm and take some files for usage:

rpm2cpio postgrey-1.34-4.fc18.noarch.rpm | cpio -idv

the you can need copy some postgrey configuration and executable files from ./usr/sbin:

./usr/sbin/postgrey
./usr/sbin/postgreyreport

to /usr/local/sbin

./etc/postfix/postgrey_whitelist_clients.local
./etc/postfix/postgrey_whitelist_recipients
./etc/postfix/postgrey_whitelist_clients

to /etc folder

then you need create postgrey working folder for postgrey database

mkdir /var/spool/exim/postgrey && chown mailnull.mail /var/spool/exim/postgrey

to start postgrey you can like this:

/usr/local/sbin/postgrey -d –unix=/var/spool/exim/postgrey/socket –exim –syslog-facility=local6 –user=mailnull –group=mail –dbdir=/var/spool/exim/postgrey –delay=60 –max-age=35 –retry-window=12h –greylist-text=Greylisted. Please, try again later. –whitelist-clients=/etc/postgrey_whitelist_clients –whitelist-recipients=/etc/postgrey_whitelist_recipients –whitelist-clients=/etc/postgrey_whitelist_clients.local –auto-whitelist-clients=5

if you can start, you maybe missing some dependencies like:

yum install perl-BerkeleyDB perl-Net-DNS perl-Net-Server perl-Digest-HMAC perl-IO-Multiplex perl-Digest-SHA1

You should create new ACL rule in your exim.conf

begin acl

# ACL that is used after the RCPT command
check_recipient:
# postgrey [TOP]

defer
log_message = greylisted host $sender_host_address
!senders = : postmaster@*
# domains = +local_domains : +relay_to_domains
!hosts = /etc/virtual/domains
!authenticated = *
verify = recipient/callout=20s,use_sender,defer_ok
set acl_m3 = request=smtpd_access_policy\n\
protocol_state=RCPT\n\
protocol_name=${uc:$received_protocol}\n\
instance=${acl_m2}\n\
helo_name=${sender_helo_name}\n\
client_address=${substr_-3:${mask:$sender_host_address/27}}\n\
client_name=${sender_host_name}\n\
sender=${sender_address}\n\
recipient=$local_part@$domain\n\n
set acl_m3 = ${sg{\
${readsocket{ /postgrey/socket/full_address }{$acl_m3}\
{5s}{}{action=DUNNO}}\
}{action=}{}}
message = ${sg{$acl_m3}{^\\w+\\s*}{}}
condition = ${if eq{${uc:${substr{0}{5}{$acl_m3}}}}{DEFER}{true}{false}}

# add “greylisted by ..seconds” header to mail which has successfully
# passed the greylisting.
warn
!senders = : postmaster@*
# domains = +local_domains : +relay_to_domains
!hosts = /etc/virtual/domains
!authenticated = *
message = ${sg{$acl_m3}{^\\w+\\s*}{}}
condition = ${if eq{${uc:${substr_0_7:$acl_m3}}}{PREPEND}{true}{false}}

# postgrey [END]

# to block certain wellknown exploits, Deny for local domains if
# local parts begin with a dot or contain @ % ! / |
deny domains = +local_domains
local_parts = ^[.] : ^.*[@%!/|]

 

After this you can restart you exim server and check if you exim use greylisting.

Leave a Reply

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