1

here are my procmail recipes:

:0
* ^Subject: [JIRA] (EDRV-*) *$
.JIRA.edrive/new

:0
* ^Subject: [SPAM] *$
.SPAM/new

:0
* ^X-Spam-Status: Yes
.SPAM/new

:0
* .*
new

I want to put my messages with [JIRA] (EDRV-XXX) in the subject into the JIRA/edrive folder of the mailbox and messages marked with [SPAM] in the subject - into the SPAM folder.

But what I am getting now:

procmail: [8652] Sat Aug 27 19:08:19 2016
procmail: Assigning "SHELL=/bin/bash"
procmail: No match on "^Subject: [JIRA] (EDRV-*) *$"
procmail: No match on "^Subject: [SPAM] *$"
procmail: No match on "^X-Spam-Status: Yes"
procmail: Match on ".*"
procmail: Assigning "LASTFOLDER=new/msg.qVktB"
procmail: Opening "new/msg.qVktB"
procmail: Acquiring kernel-lock
 Subject: [JIRA] (EDRV-100) xxxxxxx
  Folder: new/msg.qVktB><------><------><------><------><------><------>   2795

Where is a mistake?

Green Root
  • 133
  • 5

2 Answers2

2

This is a very basic regex error. In order to match [ or ( literally, you have to escape them with a backslash.

The same applies to any regex metacharacter - ., *, |, etc.

Also, to match unconditionally, simply don't put any conditions.

I'm guessing you didn't really mean to only allow whitespace after the matches, so I took those out, too. If you wanted to say "anything", that's .* in regex, but there is no point in having a condition whitch matches anything.

:0
* ^Subject: \[JIRA] \(EDRV-.*\)
.JIRA.edrive/new

:0
* ^Subject: \[SPAM]
.SPAM/new

:0
* ^X-Spam-Status: Yes
.SPAM/new

:0
new
tripleee
  • 1,416
  • 3
  • 15
  • 24
0

You need to backslash escape regex characters that you want to match as literals.

It looks like you are using your mail is stored in Maildir format. I don't know if you excluded the header or don't have one. This will deliver files to the appropriate mail subdirectories. It includes a log file so you can verify that the messages were correctly processed.

# .procmailrc - procmail configuration file

# Variable definitions
MAILDIR=$HOME/Maildir/
LOGFILE=$MAILDIR/procmail.log
DEFAULT=$MAILDIR

These rules should match the messages and deliver them to the new subfolder of the specified mailbox.

:0
* ^Subject: \[JIRA\] \(EDRV-.*\)
.JIRA.edrive/

:0
* ^Subject: \[SPAM\]
.SPAM/

:0
* ^X-Spam-Status: Yes
.SPAM/

# Anything left goes to inbox
BillThor
  • 27,737
  • 3
  • 37
  • 69