Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:"

      #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.

share|improve this question
up vote 0 down vote accepted

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} *$
share|improve this answer
wow..thanks working great! – user119720 May 22 '12 at 2:16
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 Jun 5 '14 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]$
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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