LINUX.ORG.RU
решено ФорумAdmin

Rspamd. Настроить обучение при перемещении писем.

 ,


0

1

Установлена связка Postfix + Dovecot + Rspamd.
Тестовое письмо со спамом сразу отклоняет.
Остальные письма сканирует и одобряет.
Но при перемещении писем в/из Junk/Spam, Rspamd не хочет их сканировать.
Т.е. если письмо для меня является спамом и я отправляю его в спам, то по-идее Rspamd должен его просканировать и последующие отправлять в спам.
Но этого не происходит. Это так задумано или я что-то не так настроил?
Ведь без обучения смысла от Rspamd не очень много.
В логах dovecot виден вызов rspamc, но в /var/log/rspamd/rspamd.log пусто.

# main.cf
smtpd_milters = inet:localhost:11332
milter_default_action = accept
milter_protocol = 6
# dovecot.conf
protocols = imap lmtp
mail_location = mdbox:/home/vmail/mailboxes/%d/%n

namespace inbox {
	type = private
	inbox = yes
	first_valid_uid = 76
	mail_attachment_dir = /home/vmail/mailboxes/%d/%n/attachments
	mail_attachment_hash = %{sha256}
}

namespace inbox {
	mailbox Drafts {
		auto = subscribe
		special_use = \Drafts
	}
	mailbox Spam {
		auto = subscribe
		special_use = \Junk
	}
	mailbox Trash {
		auto = subscribe
		special_use = \Trash
	}
	mailbox Sent {
		auto = subscribe
		special_use = \Sent
	}
	mailbox Archive {
		auto = subscribe
		special_use = \Archive
	}
}

protocols = $protocols sieve

protocol lmtp {
	mail_plugins = $mail_plugins sieve
}

protocol imap {
	mail_plugins = $mail_plugins imap_sieve
}

plugin {
	sieve = file:/home/vmail/sieve/%d/%n/scripts;active=/home/vmail/sieve/%d/%n/active.sieve
	sieve_before = /home/vmail/sieve/global/spam.sieve
	sieve_trace_debug = yes
	sieve_plugins = sieve_imapsieve sieve_extprograms

	# From elsewhere to Spam folder
	imapsieve_mailbox1_name = Junk
	imapsieve_mailbox1_causes = COPY
	imapsieve_mailbox1_before = file:/home/vmail/sieve/global/learn-spam.sieve

	# From Spam folder to elsewhere
	imapsieve_mailbox2_name = *
	imapsieve_mailbox2_from = Junk
	imapsieve_mailbox2_causes = COPY
	imapsieve_mailbox2_before = file:/home/vmail/sieve/global/learn-ham.sieve

	sieve_pipe_bin_dir = /usr/bin
	sieve_global_extensions = +vnd.dovecot.pipe imapsieve
}
# learn-spam.sieve
require ["vnd.dovecot.pipe", "copy", "imapsieve"];
pipe :copy "rspamc" ["learn_spam"];
# learn-ham.sieve
require ["vnd.dovecot.pipe", "copy", "imapsieve"];
pipe :copy "rspamc" ["learn_ham"];
Debug: Loading modules from directory: /usr/lib/dovecot/modules
Debug: Module loaded: /usr/lib/dovecot/modules/lib95_imap_sieve_plugin.so
Debug: Effective uid=76, gid=76, home=/home/vmail/mailboxes/example.com/mail
Debug: Namespace inbox: type=private, prefix=, sep=, inbox=yes, hidden=no, list=yes, subscriptions=yes location=mdbox:/home/vmail/mailboxes/example.com/mail
Debug: fs: root=/home/vmail/mailboxes/example.com/mail, index=, indexpvt=, control=, inbox=, alt=
Debug: Mailbox INBOX: Mailbox opened because: SELECT
Debug: Mailbox Junk: Mailbox opened because: UID COPY
Debug: Namespace : Using permissions from /home/vmail/mailboxes/example.com/mail: mode=0700 gid=default
Debug: imapsieve: mailbox Junk: COPY event
Debug: sieve: Pigeonhole version 0.5.3 (f018bbab) initializing
Debug: sieve: include: sieve_global is not set; it is currently not possible to include `:global' scripts.
Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.5.3 (f018bbab) loaded
Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.5.3 (f018bbab) loaded
Debug: imapsieve: Static mailbox rule [1]: mailbox=`Junk' from=`*' causes=(COPY) => before=`file:/home/vmail/sieve/global/learn-spam.sieve' after=(none)
Debug: imapsieve: Static mailbox rule [2]: mailbox=`*' from=`Junk' causes=(COPY) => before=`file:/home/vmail/sieve/global/learn-ham.sieve' after=(none)
Debug: imapsieve: Matched static mailbox rule [1]
Debug: sieve: file storage: Using Sieve script path: /home/vmail/sieve/global/learn-spam.sieve
Debug: sieve: file script: Opened script `learn-spam' from `/home/vmail/sieve/global/learn-spam.sieve'
Debug: sieve: Opening script 1 of 1 from `/home/vmail/sieve/global/learn-spam.sieve'
Debug: sieve: Loading script /home/vmail/sieve/global/learn-spam.sieve
Debug: sieve: Script binary /home/vmail/sieve/global/learn-spam.svbin successfully loaded
Debug: sieve: binary save: not saving binary /home/vmail/sieve/global/learn-spam.svbin, because it is already stored
Debug: sieve: Executing script from `/home/vmail/sieve/global/learn-spam.svbin'
Debug: sieve: action pipe: running program: rspamc
Debug: Mailbox Junk: UID 4: Opened mail because: mail stream
Debug: waiting for program `/usr/bin/rspamc' to finish after 0 msecs
sieve: pipe action: piped message to program `rspamc'
sieve: left message in mailbox 'Junk'
Debug: imapsieve: mailbox INBOX: FLAG event (changed flags: \Deleted)
Debug: Mailbox INBOX: Mailbox opened because: STATUS


Указали мне на проблему. Не тот порт указывал.
Вместо 11332 надо было 11334
Проверять обучение лучше всего в консоли вручную rspamc learn_spam -h localhost:11334 < message.eml
Т.к. sieve в логах не покажет ошибок, даже если они есть.
Sieve скрипты немного подправил

require ["vnd.dovecot.pipe", "copy", "imapsieve"];
pipe :copy "rspamc" ["-h", "localhost:11334", "learn_spam"];
require ["vnd.dovecot.pipe", "copy", "imapsieve"];
pipe :copy "rspamc" ["-h", "localhost:11334", "learn_ham"];

Sorcus
() автор топика
Последнее исправление: Sorcus (всего исправлений: 1)
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.