Skip to content

Exim Move all messages without PTR to Spam

Exim:

acl_check_rcpt:
...
warn
  !senders = :
  condition = ${if eq{$sender_host_name}{}{yes}{no}}
  logwrite = Host name not found for your IP address. Added header SPAM-MOVETOJUNK
  add_header = SPAM-MOVETOJUNK: Host name not found for your IP address

Sieve:

# create folder
mkdir /etc/dovecot/sieve/

#  /etc/dovecot/sieve/before.sieve
require ["fileinto"];
if exists "SPAM-MOVETOJUNK" {
    fileinto "Junk";
    stop;
}

Dovecot:

/etc/dovecot/conf.d/90-sieve.conf
plugins {
...
   sieve_before = /etc/dovecot/sieve/before.sieve
...
}
/etc/dovecot/conf.d/15-mailboxes.conf
namespace inbox {
...
  mailbox Junk {
    special_use = \Junk
    auto = create
  }

Troubleshooting

Error:

Error: sieve: binary save: failed to create temporary file: open(/etc/dovecot/sieve/before.svbin.domain.com.26932.) failed: Permission d...by 0:0 mode=0755)
Error: sieve: the lda sieve plugin does not have permission to save global sieve script binaries; global sieve scripts like /etc/dovecot/sieve/b...g the sievec tool

fix:

# id dovecot
uid=109(dovecot) gid=8(mail) groups=8(mail)

# ls -l /etc/dovecot/sieve/before.sieve
-rw-r--r-- 1 dovecot mail 72 Mar 30 14:18 /etc/dovecot/sieve/before.sieve