On Sun, 16 Mar 2025 10:26:05 -0400 (EDT) Wietse Venema via Postfix-users <postfix-users@postfix.org> wrote:
> Paul Neuwirth via Postfix-users: > > Hello List, > > > > I've a problem here and consulting web searches and AI didn't help > > much. I am trying to set up a cronjob (explanation later): (user > > vscan) "/usr/bin/fetchmail -f /etc/mail/.fetchmailrc -p IMAP -a -s > > -n --folder LearnAsHam -m '/bin/bash -c \"/usr/bin/tee > > >(/usr/bin/sa-learn --ham > > >--single)|/usr/bin/spamc|/usr/sbin/sendmail > > -i -f %F -t -- %T" '" > > > > which works as far as it gets to sendmail - which itself succeeds, > > but the mail is not being processed: > > (/var/log/mail: > > [...] 8EF10241E0: to=<p...@mail.swabian.net>, > > orig_to=<anotherlocaladdress>, relay=local, delay=35, > > delays=34/0/0/1.2, dsn=5.4.6, status=bounced (mail forwarding loop > > for p...@mail.swabian.net) > > Each time that the Postfix local delivery agent delivers a message, > it adds a Delivered-To: header with the exact envelope recipient. > > You are delivering the message twice to the same envelope recipient. > That is the definition oif a mailer loop. Dom't do that. > > Wietse Yes that's the problem. It should work like that (and does now - see further below): I manually identify false-spam and move the mail to LearnAsHam folder. The cron should make spamassassin learn it as ham and (after re-spam-checking to get rid of X-Spam-Flag) send it again to me. I have worked it out. and as you said, "Delivered-To:" header was the culprit. my original command had some other major issues. It made my mail server a spam slinger, as mails got resent to all recipients. 2ndly the output of sa-learn was appended to the message, which broke some. I ended up with this cron commands: /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 >&2 )|/usr/bin/spamc|/usr/bin/formail -i"Message-ID:" -i"Received:" -i"Return-Path:" -i"To:" -i"Cc:" -i"Bcc:" -i"Delivered-To:"|/usr/sbin/sendmail -i -f \%F p...@mail.swabian.net -- \%T" ' /usr/bin/fetchmail -f /etc/mail/.fetchmailrc -p IMAP -a -s -n --sslcertck --sslcommonname mail.swabian.net --folder LearnAsSpam -m '/bin/bash -c "/usr/bin/tee >(/usr/bin/sa-learn --spam --single >&2 )|/usr/bin/spamc|/usr/bin/formail -i"Message-ID:" -i"Received:" -i"Return-Path:" -i"To:" -i"Cc:" -i"Bcc:" -i"Delivered-To:"|/usr/sbin/sendmail -i -f \%F p...@mail.swabian.net -- \%T" ' 3 changes: -sa-learn stdout sent to stderr (I want it in the cron output) -formail to get rid of some headers -sendmail with fixed To:-address for the mailbox. Don't know if this is an elegant solution for the purpose. But it is working as desired. Regards, Paul > > > I spent some hours trying to get rid of a configured forwarding > > loop. But there doesn't seem to be any. > > sending to <anotherlocaladdress> and p...@mail.swabian.net works > > from several of local hosts. > > > > I think it must have to do with the chaining of fetchmail and > > sendmail leaving all headers intact - trying to send an already > > delivered message again. > > > > What the cronjob is for: > > fetchmail gets mails of folder "LearnAsHam", where I put > > false-positive spam-mails. it is sent to sa-learn --ham to make > > spamassassin learn it as ham. then it gets sent to spamc and to > > sendmail to re-deliver the message. > > (and an identical cronjob for "LearnAsSpam" with "sa-learn --spam") > > > > Any idea of how to get those mails delivered and not bounced? > > > > Any help appreciated, thank you very much > > > > Regards, > > > > Paul _______________________________________________ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org