Gentoo Archives: gentoo-user

From: reader@×××××××.com
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: OT: Any way to run files through procmail?
Date: Tue, 27 Jun 2006 12:29:11
Message-Id: 87veqmssbt.fsf@newsguy.com
In Reply to: Re: [gentoo-user] OT: Any way to run files through procmail? by Farhan Ahmed
1 Farhan Ahmed <farhanahmed06@×××××.com> writes:
2
3 > Jorge Almeida wrote:
4 >> On Thu, 22 Jun 2006, Jamie wrote:
5 >> >The emails are sitting in individual files in a Maildir on the machine
6 >> >that should have processed them. Is there any way to run procmail over
7 >> >all of the messages in the Maildir so I don't have to manually forward
8 >> >each message back to myself so that procmail will process them when the
9 >> >come back in.
10 >>
11 >> procmail [-m /path/to/your/procmailrc] < /path/to/message
12 >>
13 >> This will deliver the message contained in the individual file
14 >> /path/to/message. You'll have to iterate over all such files.
15 >
16 > Will this work for mbox format as well?
17
18 To answer your question... yes it should.
19
20 There is an example of how to process missed mail or reprocess
21 misprocessed mail in `man procmail' . Look for the paragraph
22 that begins:
23
24 Procmail can also be invoked to postprocess an already filled
25 system mailbox. This can be useful if you don't want to or
26 can't use a $HOME/.forward file (in which case the following
27 script could periodi- cally be called from within cron(1), or
28 whenever you start reading mail):
29 [...]
30 Nice example follows that para.
31
32 Depending on scale you may want to do a little more and setup a
33 sandbox for procmail experiments and runs of procmail outside the
34 normal setup.
35
36 Its pretty easy to do. Then you can run test runs and see exactly
37 what will happen. Once happy with results then run with your normal
38 .procmailrc.
39
40 Such a setup might look like:
41
42 mkdir -p proc/spool
43
44 cd proc
45 create a procrc file that has this header:
46
47 cat ./procrc
48
49 ----- 8< snip -------
50 PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin
51 SHELL=/bin/sh
52 MAILDIR=/home/YOU/proc/spool
53 LOGFILE=/home/YOU/proc/.prclog
54 ORGMAIL=/home/YOU/proc/spool/$LOGNAME
55 DEFAULT=$ORGMAIL
56 VERBOSE=YES
57
58 ####################################
59
60 ####### Test recipes below here ############
61
62
63 ----- 8< snip -------
64
65 Add the rules from your working rc file.
66
67 What the above settings will do is:
68 `MAILDIR=/home/YOU/proc/spool'
69 sets the spool to be written to at the spool directory in your test
70 area. So a rule like:
71
72 0:
73 * ^To:.*me@some\.com
74 me
75
76 Will write any mail with To: me@××××.com to /home/YOU/proc/spool/me
77 The point here is that you can now run test procmail runs without
78 fear of writing to working mail spool. Stuff will be deliverd to
79 your test area instead.
80
81 `ORGMAIL=/home/YOU/proc/spool/$LOGNAME'
82 Would normally be set to /var/spool/mail/$LOGNAME (by default)
83 But now is set to your practice area
84
85 `DEFAULT=$ORGMAIL'
86 Sets the default delivery point in case something doesn't match any
87 rules it goes to $ORGMAIL
88
89 `VERBOSE=YES'
90 Kind of speaks for itself... will put more usefull info in
91 /home/YOU/proc/.prclog
92
93 Now you can cd to the unprocessed mail directory and if it is one msg
94 per file you could just cat it all together int ./bigcat
95 (Assuming it has a leading `From .........' line and will compile like a
96 large mbox file.)
97
98 Or if alread in mbox format then you make test runs like this:
99
100 cat MailToProcess| formail -e -s procmail -m /home/YOU/proc/procrc
101
102 (formail -e is added to handle the case where messages do not have a
103 separating blank line.)
104
105 In the above command and with the posted procrc (with your rules) mail
106 will be processed like usual but deliverd to your test area instead of
107 to real working spool.
108
109 This way you can iron out any bugs before you make the real run
110 where you would just substitute the normal working rc file for
111 ./procrc.
112
113
114 --
115 gentoo-user@g.o mailing list