LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   procmail recipe to filter email to different folder (https://www.linuxquestions.org/questions/linux-server-73/procmail-recipe-to-filter-email-to-different-folder-4175443062/)

newbie.my 12-26-2012 10:00 PM

procmail recipe to filter email to different folder
 
Hi everyone,

The tittle said it all.
Currently my procmail recipe are as below:

Code:

FROM_=`formail -c -x"From "| awk '{ print $1 }'`

  SUBJ_=`formail -c -x"Subject:" | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`

  :0
  *^Subject:.*(60)


  {
  :0 fwh
  | formail | (echo "$FROM_"; echo "$SUBJ_";)

  :0 fwb
  | formail -I ""


  :0
  myemail/
  }

My procmail recipe will only filter out the email that have number "60" it its subject.After that formail will execute taking out the information of the sender email and its subject before forwarding it together with its content to "myemail" folder.

Can someone help me to construct a procmail recipe to filtering incoming mails into different folders if there are multiple "60" seperated by commas in the subjects?

(For example,the email with subject 6010,6011,6012,.. the 6010 will go into 6010 folder,6011 will go into 6011 and so on.)

I really appreciate it if anybody can help me.Thanks.

unSpawn 12-28-2012 08:36 AM

I't s bit of a "greedy match" but can't you just use "*^Subject:.*60.*$"?

newbie.my 12-30-2012 10:46 PM

Quote:

Originally Posted by unSpawn (Post 4858422)
I't s bit of a "greedy match" but can't you just use "*^Subject:.*60.*$"?

Yup..greedy match expression is what I'm looking for.
Btw the method that you suggest does not working.
Do you have any other suggestion?
Maybe there is another way to do this by phrasing the Subject information by using sed or awk before passing it to the procmail?


All times are GMT -5. The time now is 01:26 PM.