[rt-users] RE: PROCMAIL

George Warnagiris gwarnagiris at babcockbrown.com
Tue Feb 5 17:18:07 EST 2002


I just wanted to let you know that your advice has been very instrumental in
helping to get this going.  I have successfully implemented and tested the
disclaimer filter.  I really appreciate the time you have spent on this
issue.  I owe you a beer next time you're in NYC.

For the list, here is my final /etc/aliases entry, procmail recipe and perl
script.  I hope this helps.


RELEVANT /etc/aliases FILE:
> #RT STuff
> helpdeskus: "| /usr/bin/procmail -m /etc/procmailrcs/disclaim-filter"
> #helpdeskus: "| /opt/rt2/bin/rt-mailgate --queue helpdeskus --action
> correspond"

> #This file must be owned by the rt user
> HOME=/home/rt
> INCLUDERC=$HOME/.procmailrc
> LOGFILE=/tmp/disclaimstrip.log
> SHELL = /bin/bash
> 0
> ! me at domain
> So now procmail is acting as the user "rt".  Here's were it all 
> happens, the > INCLUDERC file /home/rt/.procmailrc:
> # This file does any filtering/mail manipulations/etc before # calling
> rt-mailgate.
> HOME=/home/rt
> LOGFILE=log/procmail.log
> # Place mailfiltering here
> :0 wfb
>         |/usr/local/scripts/strip.disclaim
> 0
>         {
> # Use a lockfile to ensure only one rt-mailgate process.
>         :0:.procmail.lock
>         |/opt/rt2/bin/rt-mailgate --queue helpdeskus --action correspond
> # Something went wrong.  Dump it to someone
>         :0e
>         ! me at domain
> }
> And finally, here is the real simple perl script:
> #!/usr/bin/perl -w
> undef $/; #We want to treat STDIN as one line
> $input = <>;
> $input =~ s/This email message may contain information(.*?)free of 
> errors or
> viruses.//smg;
> $/ = "\n";
> print $input;

-----Original Message-----
From:	Bruce Campbell [mailto:bruce_campbell at ripe.net]
Sent:	Tuesday, February 05, 2002 5:30 AM
To:	George Warnagiris
Cc:	rt-users at lists.fsck.com
Subject:	Re: [rt-users] RE: PROCMAIL

On Mon, 4 Feb 2002, George Warnagiris wrote:

> disclaimer before it hits RT.  I have created a procmail recipe that uses
> perl to strip the unwanted text.  I though this should be invoked in the
> aliases file like this:
> helpdeskus: "| procmail /etc/.procmailrc | /opt/rt2/bin/rt-mailgate
> helpdeskus --action correspond"
> It, unfortunately, sends a blank, header-less, body-less email to RT.  I'm
> not sure what I'm doing wrong here.  I thought you may be able to suggest

You would be better off invoking rt-mailgate from within the procmailrc.
I do my mail delivery to RT via:

aliases file:
	# Run rt2 as the rt2 user, not as root.
	test-rt2:           "| /usr/bin/procmail -m


	# This file MUST be owned by the rt2 user.  See '-m' description
	# in the procmail man page.

	# are we still here after including?  Dump it to someone
	! joe_bloggs at example.com

( The above two snippets gets procmail running, as the rt2 user, a
  procmail file for the specific queue.  I really really dislike relying
  on setuid stuff. )


	# This file does any filtering/mail manipulations/etc before
	# calling rt-mailgate.


	# Go away you naughty annoying spammer
	* ^From:.*badguy at example.com

	# Place mailfiltering here
	:0 f
	| /home/rt2/bin/my_custom_filter_program

	# Accept the mail into mailgate.  We { } enclose it incase we want
	# a last-ditch filter.
	  # Use a lockfile to ensure only one rt-mailgate process.
	  :0 :.procmail.lock
	  | /home/rt2/bin/rt-mailgate --queue TEST --action correspond

	  # Something went wrong.  Dump it to someone
	  ! joe.bloggs at example.com


                             Bruce Campbell                            RIPE
                   Systems/Network Engineer                             NCC
                 www.ripe.net - PGP562C8B1B                      Operations

This email message may contain information that is confidential and
proprietary to Babcock & Brown or a third party.  If you are not the
intended recipient, please contact the sender and destroy the original and
any copies of the original message.  Babcock & Brown takes measures to
protect the content of its communications.  However, Babcock & Brown cannot
guarantee that email messages will not be intercepted by third parties or
that email messages will be free of errors or viruses.

More information about the rt-users mailing list