0

I have a Centos 7 server setup with Postfix, Spamassassin and procmail. It works fine, it receives and sends email , it passes it to the spam filter and delivers it to the required user or external email address.

The problem is, if I have a procmail recipe that processes mail, and then forwards it to an external address, this does not happen. On my previous Centos 6 server (with sendmail) this worked fine. The type of procmail recipe I am using is:

:0H
* ^X-Spam-Score:        * (\*\*\*\*\*\*\*\*\*\*
/dev/null


:0H
* ^X-Spam-Score:        * (\*\*\*\*\
$HOME/mail/Spam

:0
!email@example.com

Any ideas?

0

You have syntax errors in both regexes. You cannot have an opening parenthesis without a closing parenthesis, and you cannot have your regex end with a backslash. (Or rather, the destination folder becomes part of your regex, but then you cannot have a recipe without a destination folder or other action.)

The parentheses seem superfluous here anyway; I guess you want

:0H
* ^X-Spam-Score:[     ]*\*\*\*\*\*\*\*\*\*\*
/dev/null

:0H
* ^X-Spam-Score:[     ]*\*\*\*\*\*
$HOME/mail/Spam

where the two occurrences of [ ]* should have a space and a tab between the square brackets to match arbitrary whitespace before the literal asterisks; and the first recipe matches ten literal asterisks, anl the second, five. (Add more if you wanted more, or take away some if vice versa.)

For troubleshooting Procmail, defining a LOGFILE and examining the diagnostics in it is usually a good first step. There's a troubleshooting page at http://www.iki.fi/era/mail/procmail-debug.html with more guidance and other things you can try.

  • Then opening parenthesis is a literal character in the regex string. This recipe has been working correctly for 5 years or more. Are you suggesting I should escape the opening bracket? Thanks, Jim – JIm Rolt Sep 23 '18 at 8:24
  • Yes, you need \( to match a literal opening parenthesis. And again, define LOGFILE so you can see and react to any error messages from Procmail. – tripleee Sep 23 '18 at 9:39
  • Thanks for the tip! I tried it this and it's made no difference to either the spam filtering(which was, and is, fine) or the forwarding of procmail filtered emails as a forward. I sense this is a problem of procmail failing to pick up the email again after filtering; procmail is configured to use port 2525 and send via mailgun as this is a google cloud server with port 25 unavailable... any further ideas will be very welcome! – JIm Rolt Sep 26 '18 at 17:40
  • Procmail doesn't use a port number; I guess you mean Postfix is? If you are not currently managing to get Postfix to run Procmail when an incoming message arrives, that's a completely different question, where we need to see your Postfix configuration. – tripleee Sep 27 '18 at 4:32
  • Or do you mean Procmail runs but sendmail in the forwarding action fails? Same thing though, we need to troubleshoot your sendmail (which is probably in your case a wrapper from the Postfix package). – tripleee Sep 27 '18 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.