On Tue, 18 Mar 2025 08:08:37 +0100 Paul Neuwirth via Postfix-users <postfix-users@postfix.org> wrote:
> On Mon, 17 Mar 2025 10:41:47 +0100 > Benny Pedersen via Postfix-users <postfix-users@postfix.org> wrote: > > > Paul Neuwirth via Postfix-users skrev den 2025-03-17 09:16: > > > > > thank you for the suggestion. > > > I found this thread in a forum, which seems to be exactly my > > > use-case: > > > https://forums.gentoo.org/viewtopic-t-829416-start-0.html > > > > https://dovecot.dovecot.narkive.com/BcwsH9DF/getmail-and-lda-deliver > > > > then fetchmail works aswell if mda is used in fetchmailrc > > > got it. needed some debugging, dovecot-lda didn't want to deliver to > the user running as vscan, tried to change auth, group. but ended up > using sudo. > > so commands are now: > /usr/bin/fetchmail -f /etc/mail/.fetchmailrc -a -s -n --folder > LearnAsHam -m '/bin/bash -c "/usr/bin/tee >(/usr/bin/sa-learn --ham > --single 1>&2)|/usr/bin/spamc|/usr/bin/sudo -u USERNAME > /usr/lib/dovecot/deliver -k -d USERNAME -m INBOX"' > and > /usr/bin/fetchmail -f /etc/mail/.fetchmailrc -a -s -n --folder > LearnAsSpam -m '/bin/bash -c "/usr/bin/tee >(/usr/bin/sa-learn --spam > --single 1>&2)|/usr/bin/spamc|/usr/bin/sudo -u USERNAME > /usr/lib/dovecot/deliver -k -d USERNAME -m INBOX"' last update, hopefully. I dislike, that the re-delivered messages get at the end of the list (so first new message). I don't know why I didn't think of it before. I use imapfilter for other things (archiving... maillist management...). And it supports a pipe_to(). So I did the following config: results = mailbox["LearnAsSpam"]:select_all() for _, mesg in ipairs(results) do mbox, uid = table.unpack(mesg) text = mbox[uid]:fetch_message() if (pipe_to('/usr/bin/sudo -u vscan /usr/bin/sa-learn --spam --single 1>&2', text) == 0) then spamlist = Set {} table.insert(spamlist, mesg) spamlist:move_messages(mailbox.spam) end end results = mailbox["LearnAsHam"]:select_all() for _, mesg in ipairs(results) do mbox, uid = table.unpack(mesg) text = mbox[uid]:fetch_message() if (pipe_to('/usr/bin/sudo -u vscan /usr/bin/sa-learn --ham --single 1>&2', text) == 0) then spamlist = Set {} table.insert(spamlist, mesg) spamlist:move_messages(mailbox.spam) end end I just miss the part, that the mail doesn't get processed by spamc again. but I can send the mail to sa-learn and then move the message (instead of re-deliver). happy now. _______________________________________________ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org