[rt-users] Blocking mail to RT

Stephen Turner sturner at MIT.EDU
Wed Feb 15 10:13:12 EST 2006


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




More information about the rt-users mailing list