Blocking mail to RT

I need to block certain mail from being accepted by RT.

Will the email plugin facility help for this? I know now that at scrip
time, it is to late, since it has already been loaded into the database
at that time.
I need to block any new email coming in, that has CC addresses.

Regards
Leon

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

I am very interesting on this area too.

Any suggestion is much appreciated.

  • Wang

Leon wrote:

I suspect that you will need to scrub the CC addresses before it hits
RT. Or check RT_SiteConfig.pm for $ParseNewMessageForTicketCcs to
prevent RT from adding them as ticket watchers.

Leon wrote:

I need to block certain mail from being accepted by RT.

Will the email plugin facility help for this? I know now that at scrip
time, it is to late, since it has already been loaded into the
database at that time.
I need to block any new email coming in, that has CC addresses.

Regards
Leon

Drew Barnes
Applications Analyst
Raymond Walters College
University of Cincinnati

At Wednesday 2/15/2006 04:45 AM, Leon wrote:

I need to block certain mail from being accepted by RT.

Will the email plugin facility help for this? I know now that at scrip
time, it is to late, since it has already been loaded into the database at
that time.
I need to block any new email coming in, that has CC addresses.

Regards
Leon

You could use a scrip to immediately delete these tickets - that’s not
really blocking, but at least you wouldn’t see the tickets.

Alternatively, assuming you want RT to handle this task, you could write a
mail filter. I couldn’t see anything on the wiki about this - here’s a
quick summary of something we did:

  1. Create a perl module to handle the filtering - call it MyFilter.pm or
    whatever, and put it in $RT_HOME/local/lib/RT/Interface/Email/Filter (see 3
    below for detail).

  2. Tell RT to use the filter. In RT_SiteConfig.pm:

     @RT::MailPlugins = ("Filter::MyFilter", "Auth::MailFrom");
    
  3. The code for the filter is (briefly):

BEGIN FILTER CODE

package RT::Interface::email::Filter::MyFilter;

The plugin engine calls GetCurrentUser to pass judgement on a message.

Return (undef, 0) when mail is allowed, (undef, -1) when it should be

dropped.
sub GetCurrentUser {
local $_;

 my %args = (
     Message     => undef,
     CurrentUser => undef,
     AuthLevel   => undef,
     @_
 );

YOUR LOGIC HERE

}
1;

END FILTER CODE

where pseudocode for the “YOUR LOGIC HERE” piece would be:

IF you want the mail
return (undef, 0)
ELSE
return (undef, -1)
ENDIF

You can look at mail headers in this code like this:

$args{‘Message’}->head()->get(‘Some-Mail-Header’);

Hope this all makes sense and that I haven’t missed anything out.
Steve

Leon rt@tux.datalink.co.za writes:

I need to block certain mail from being accepted by RT.

So never send it to RT.

Things like this is better implemented outside RT. For example, I use
procmail to stop spam from entering RT at all.

Leif Nixon - Systems expert
National Supercomputer Centre - Linkoping University

Hello.

I´m using procmail in a linux box to block the undesired mail going to rt
system. A sample of my .procmailrc its at the end

Hope it helps

Regards

-luis

$ cat $HOME/.procmailrc
SHELL=/bin/bash
SPAMDIR= /var/tmp/spam/date +%Y-%m
DUMMY=test -d $SPAMDIR || (mkdir -p $SPAMDIR; chmod 755 $SPAMDIR)

Spam

:0 c

  • ? formail -x"Subject:"
    | egrep -i ‘[SPAM]’;
    $SPAMDIR/

Refuse mail from myself

:0

  • ? formail -x"From:" -x"Reply-To:" -x"Errors-To:"
    | egrep -i ‘mydomain’
    ! spamtrap@mydomain

Cron mail should be looked upon

:0

  • ? formail -x"From:" -x"Reply-To:" -x"Errors-To:"
    | egrep -i ‘Cron Daemon’
    ! Root

Refuse bounces

:0

  • ? formail -x"From:" | egrep -i MAILER-DAEMON
    /dev/null

All mails bigger than 1.5 Mb are sent to an administrator instead

:0

  • 1500000
    ! root

Send the mail to rt engine

:0
|perl -MMail::Message -e ‘$msg = Mail::Message->read(*STDIN); if
(length($msg->
subject)>= 70) {my $newsubject = substr($msg->subject,0,67) . “…”; my
Mail::Me
ssage::Head $head = $msg->head; $head->delete(‘Subject’);
$head->add(Subject =>
$newsubject)} $msg->print()’|/opt/rt3/bin/rt-mailgate --queue dnsbls
–action c
orrespond --url http://myrt/