Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to ask regarding the procmail recipes.

Here is my recipe so far:

:0
     * ^X-Loop: myemail@gmail\.com
     /dev/null

     :0

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


    {
      :0c:
      ${DEFAULT}

     # :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: myemail@gmail.com"


      #Forward to the other folder
      :0
      TESTNEW/
      }

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

2 Answers 2

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 @mgroven.it 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 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

 
discard

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.