I am unable to reproduce your problem, and you are not posting any diagnostics, but I can suggest a different recipe which might avoid a couple of possible error conditions.
There is no reason to repeat the
List-Unsubscribe: conditions inside the braces -- if you are inside the braces, you know it matched.
The convention to hard-code the path to
formail seems clunky (and you fail to do that in one of the places where you call it) but if Procmail gets invoked with a really wonky
PATH that could be a reason you see failure when you don't specify fully the path
Anyway, you want to avoid external processes as far as possible. Procmail can extract the Subject: header into
MATCH and then you just need a single
formail invocation for the entire recipe to succeed.
| /usr/bin/formail -i "Subject: [BULKMAIL]$MATCH"
The special operator
\/ causes Procmail to collect the matching string into the variable
MATCH, and we then use that instead of the external
formail -xSubject: you were running. This is hardly a crucial change, but should be more efficient, as well as easier to read and debug.
(The trailing wildcard
.* is superfluous in the first regex; Procmail is satisfied if a match is found anywhere in a line.)
You can test from the command line (but this of course requires that your recipe file doesn't override
root@vbvntv-docker:/# procmail DEFAULT=/dev/null VERBOSE=yes </tmp/nst.eml
procmail:  Thu Dec 1 06:57:20 2016
procmail: Rcfile: "/etc/procmailrc"
procmail: Assigning "PATH=/usr/local/bin:/usr/bin:/bin"
procmail: Match on "^List-Unsubscribe:"
procmail: Assigning "MATCH="
procmail: Matched " testing"
procmail: Match on "^Subject:\/.+"
procmail: Executing " /usr/bin/formail -i "Subject: [BULKMAIL]$MATCH""
procmail: Assigning "PATH=/root/bin:/usr/local/bin:/usr/bin:/bin"
procmail: Assigning "LASTFOLDER=/dev/null"
procmail: Opening "/dev/null"
procmail: Notified comsat: "root@0:/dev/null"
From foo@bar Thu Dec 1 06:57:20 2016
Subject: [BULKMAIL] testing
Folder: /dev/null 133
If you still can't get this to work, updating your question with a similar transcript whould be most helpful. Further troubleshooting tips can be found e.g. at http://www.iki.fi/era/mail/procmail-debug.html
Once you are satisfied that your code works, maybe you'll want to prefer
formail -I over
formail -i which leaves the now rather useless
Old-Subject: in the headers.
(Your prose description says
BULK but the code says
BULKMAIL. It is obviously easy to change if your code was wrong.)
The Webmin stuff is truly atrocious but apparently it's not your own code. Somebody should supply the Webmin folks with a hint that Procmail contains a regex engine, so calling
/bin/test to compare two strings is really, really inefficient and generally horrendous.