ubuntu_exim_mysql_greylisting
mysql -uroot -p
USE exim;
CREATE TABLE exim_greylist (
  id integer NOT NULL auto_increment,
  relay_ip varchar(64),
  from_domain varchar(255),
  block_expires datetime NOT NULL,
  record_expires datetime NOT NULL,
  origin_type enum('MANUAL','AUTO') NOT NULL default 'AUTO',
  create_time datetime NOT NULL,
  PRIMARY KEY (id)); 
QUIT
vi /etc/exim4/exim4.conf
#MACROS
GREYLIST_TEST = SELECT CASE \
   WHEN now() - block_expires > 0 THEN 2 \
   ELSE 1 \
 END \
 FROM exim_greylist \
 WHERE relay_ip = '${quote_mysql:$sender_host_address}' \
  AND from_domain = '${quote_mysql:$sender_address_domain}'

GREYLIST_ADD = INSERT INTO exim_greylist (relay_ip, from_domain, \
  block_expires, record_expires, create_time) \
  VALUES ( '${quote_mysql:$sender_host_address}', \
  '${quote_mysql:$sender_address_domain}', \
  DATE_ADD(now(), INTERVAL 5 MINUTE), \
  DATE_ADD(now(), INTERVAL 7 DAY), \
  now())
   
GREYLIST_USERS = ${lookup mysql{SELECT login FROM users \
  WHERE login='${quote_mysql:$local_part}' \
  AND domain='${quote_mysql:$domain}' \
  AND grey='yes'}}
...

#ACL CONFIGURATION
begin acl
acl_check_rcpt:
...
  warn set acl_m2 = ${lookup mysql{GREYLIST_TEST}{$value}{0}}

  defer message = Greylisted - please try again a little later.
        condition = ${if eq{$acl_m2}{0}{1}}
        condition = ${lookup mysql{GREYLIST_ADD}{yes}{no}}
        condition = ${if eq{$local_part}{GREYLIST_USERS}{yes}{no}}

  defer message = Greylisted - please try again shortly.
        condition = ${if eq{$acl_m2}{1}{1}}
        condition = ${if eq{$local_part}{GREYLIST_USERS}{yes}{no}}

  accept domains = +local_domains
         endpass
         message = unknown user
         verify = recipient

  accept domains = +relay_to_domains
         endpass
         message = unrouteable address
         verify = recipient

  deny message = relay not permitted

Теперь кому вы поставите отметку yes в поле grey, у тех будет включен greylisting.

ubuntu_exim_mysql_greylisting.txt · Last modified: 2023/06/09 12:00 by admin