procmail
[Top] [All Lists]

Re: Email Filters

2009-06-18 10:31:05
At 09:44 2009-06-18 -0400, rmp dmd wrote:
I wished I can do this on user level but I cannot.

Not to fear.

Where can I set my filter globally, so that email for

You don't need to do it globally then - you can modify the alias to invoke it there, passing the existing commandline (minus the leading pipe) as an argument to procmail, like so:

prod1: "|/usr/bin/procmail -m /etc/procmailrcs/prod1.rc \"/opt/rt3/bin/rt-mailgate --queue prod1 --action correspond --url <http://srv1.domain.net/rt/>http://srv1.domain.net/rt<http://srv1.domain.net/rt/>/\""

Note especially that the original commandline has _escaped_ quotes around it. This is so that it passes along to the first program as a single parameter.

BEFORE making that change though:

mkdir /etc/procmailrcs

Paste the following into say, /etc/procmailrcs/prod1.rc :

#-----------

# the path for the logfile and the mailbox are somewhat arbitrary for
# this - you should make an appopriate directory for them, but I'm coding
# this to /var/log/ because it should exist and have space.  Since this is
# intended to be invoked by a privledged user, this shouldn't be a problem.

SHELL=/bin/bash
LOGFILE=/var/logs/testing_prod1.pmlog
VERBOSE=ON


# oops, yesterday, I omitted the lockfile flag (the colon AFTER the zero
# below) from this recipe - it's needed when actually writing to a file, but
# *NOT* necessary when you revise this to deliver to /dev/null, which is my
# original mindset in not having the flag when I posted yesterday
# FTR, the brackets contain a space and a tab.
:0:
* 9876543210^0 ^From:[ ]*\<<mailto:alertnotications(_at_)ml(_dot_)com>alertnotications(_at_)ml\(_dot_)<mailto:alertnotications(_at_)ml(_dot_)com>com
* 9876543210^0 ^Subject:[       ](failure notice|\*\* RECOVERY .* OK \*\*)
/var/log/testing_proc1_discard.mbx

# handle default condition - but not using "default" mailbox, but rather
# the commandline arg.
:0
|$1

#-----------

I've used the technique quite a bit myself, even on large production listservs. Even so, after composing the procmailrc stuff, I'd consider setting up a SEPARATE alias and throw some test messages at it to see that nothing goes wrong. File permissions and issues specific to your system configuration for instance. When you know that works, change the aliases to make it live, and check the logfile to see that you've got good filtering activity with the actual messages.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>