Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 12-26-2012, 11:00 PM   #1
LQ Newbie
Registered: Jun 2012
Posts: 6

Rep: Reputation: Disabled
Question procmail recipe to filter email to different folder

Hi everyone,

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

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

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


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

   :0 fwb
   | formail -I ""

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.

Last edited by; 12-26-2012 at 11:24 PM.
Old 12-28-2012, 09:36 AM   #2
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
I't s bit of a "greedy match" but can't you just use "*^Subject:.*60.*$"?
Old 12-30-2012, 11:46 PM   #3
LQ Newbie
Registered: Jun 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Originally Posted by unSpawn View Post
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?


centos5, email, fetchmail, procmail

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Procmail Recipe: Need help vaibhavs Linux - Newbie 1 10-20-2009 02:59 PM
Anyone Filter Email w/ Procmail carlosinfl Linux - Server 10 03-14-2008 04:07 PM
Procmail recipe question gauge73 Linux - Software 3 05-03-2006 05:09 AM
Procmail recipe jebix666 Linux - General 1 06-09-2005 02:43 PM
MS Security Virus Email bypasses Procmail Filter lewt Linux - Security 3 09-24-2003 07:32 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration