I want to ask regarding the procmail recipes.

Here is my recipe so far:

     * ^X-Loop: myemail@gmail\.com


     * ^Subject:.*(mytext)
    # * ^Subject:.*(phonenumber)


     # :0 fwh
     # * ^Content-Lentgh:
     # | formail -z -i"Content-Lentgh:"

      #Add the loop avoidance
      # ( f for piping; w for waiting for completion; h for header )
      #:0 fwh
      #| formail -A"X-Loop: [email protected]"

      #Forward to the other folder

Here's the problem:

I want to make filtering based on the phone number of the subject sender(ex:60102348677,etc...)because I want to send the content of this particular email to our own sms gateway.

The settings for other things has been setup and working fine except for this one.

Can anyone show me any way which can solve my problem? Thanks.

2 Answers 2


If you're looking for the condition to match these messages, then this should do what you want (it matches a subject line only containing 11 consecutive digits):

^Subject: *[0-9]{11} *$
  • using the {#} broke my expression, I had to repeat [0-9] however many numbers I needed. Not sure why, I'm using procmail.x86_64, 3.22-25.1.5.amzn1. So I did this: * ^Subject: *photo(s)? (for|of) [0-9][0-9][0-9][0-9][0-9][0-9] * since this didn't work: * ^Subject: *photo(s)? (for|of) [0-9]{6}$ . What version of procmail did this work in for you? PS. I also noticed that the 0 to many spaces at the end " *" would allow 0 to many digits, so I got rid of that too.
    – radtek
    Commented Jun 5, 2014 at 15:55

This is the alternative if the above doesn't work for you as it didn't work for me using the squiggly brackets approach. Perhaps it has something to do with the procmail or egrep version. This works but is rather long:

* ^Subject: *[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .