Home > Uncategorized > Сортировка почты с помощью Dovecot Sieve

Сортировка почты с помощью Dovecot Sieve

Что имеется: postfix + mysql + dovecot как imap сервер + roundcube
Задача: сделать так, что бы письма с пометкой SPAM ложились в каталог Junk, а не Inbox.

Собираем Dovecot с поддержкой LDA:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@case.net.ru]$ cd /usr/ports/mail/dovecot
[root@case.net.ru]$ make showconfig
===> The following configuration options are available for dovecot-1.1.11:
     KQUEUE=on "kqueue(2) support"
     SSL=off "SSL support"
     IPV6=off "IPv6 support"
     POP3=off "POP3 support"
     LDA=on "LDA support"
     MANAGESIEVE=off "ManageSieve support"
     GSSAPI=off "GSSAPI support"
     VPOPMAIL=off "VPopMail support"
     BDB=off "BerkleyDB support"
     LDAP=off "OpenLDAP support"
     PGSQL=off "PostgreSQL support"
     MYSQL=on "MySQL support"
     SQLITE=off "SQLite support"
===> Use 'make config' to modify these settings
[root@case.net.ru]$ make install clean

Устанавливаем dovecot-sieve:

1
2
[root@case.net.ru]$ cd /usr/ports/mail/dovecot-sieve/
[root@case.net.ru]$ make install clean

Настраиваем postfix:
Добавляем в master.cf:

1
2
dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/local/libexec/dovecot/deliver -f ${sender} -d ${recipient}

Меняем в main.cf:

1
virtual_transport = dovecot

Меняем в dovecot.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
protocol lda {
  postmaster_address = case@case.net.ru
  hostname = case.net.ru
  mail_plugins = cmusieve
  mail_plugin_dir = /usr/local/lib/dovecot/lda
  sendmail_path = /usr/sbin/sendmail
  sieve_global_path = /usr/home/vmail/dovecot-sieve.conf
}
 
auth default {
  socket listen {
    master {
      path = /var/run/dovecot/auth-master
      mode = 0600
      user = vmail
      group = vmail
    }
  }
}

Настраиваем sieve в файле /usr/home/vmail/dovecot-sieve.conf:

1
2
3
4
require "fileinto";
if header :contains "Subject" "SPAM" {
  fileinto "Junk";
}
  1. No comments yet.
  1. No trackbacks yet.