[rt-users] Maximum recipients allowed

Olivier Lumineau olivier.lumineau at renater.fr
Thu Feb 5 07:31:05 EST 2015


Le 03/02/2015 17:37, Olivier Lumineau a écrit :
>
> Le 19/05/2014 15:02, ktm at rice.edu a écrit :
>> On Mon, May 19, 2014 at 02:41:19PM +0200, Olivier Lumineau wrote:
>>> Hi,
>>> we are using RT 3.8.7, and to filter spam more efficiently, I wanted
>>> to know if there was an easy way in RT to limit ticket recipients
>>> (to + cc + bcc) .
>>>
>>> I don't want more than 10 or 15 recipients by ticket, to prevent
>>> that a spam withs hundreds mail addresses pollute our RT.
>>>
>>> Thanks
>>>
>>> -- 
>>> Olivier
>>>
>> Hi Olivier,
>>
>> I used the following in Email_Local.pm. Maybe you can do something 
>> similar.
>>
>> Regards,
>> Ken
>> -----------------------
>> sub ParseCcAddressesFromHead {
>>      my %args = (
>>          Head        => undef,
>>          QueueObj    => undef,
>>          CurrentUser => undef,
>>          @_
>>      );
>>
>>      my @recipients =
>>          map lc $_->address,
>>          map Email::Address->parse( $args{'Head'}->get( $_ ) ),
>>          qw(To Cc);
>>
>>      my @res;
>>      foreach my $address ( @recipients ) {
>>          $address = 
>> $args{'CurrentUser'}->UserObj->CanonicalizeEmailAddress( $address );
>>          next if lc $args{'CurrentUser'}->EmailAddress   eq $address;
>>          next if lc $args{'QueueObj'}->CorrespondAddress eq $address;
>>          next if lc $args{'QueueObj'}->CommentAddress    eq $address;
>>          next if RT::EmailParser->IsRTAddress( $address );
>>
>>          push @res, $address;
>>     }
>>
>>      #
>>      # Limit the number of Cc addresses that we add to a
>>      # ticket during the initial create to minimize damage
>>      # to our Email reputation when SPAM slips through DSPAM.
>>
>>      $RT::Logger->debug("$#res Ccs");
>>      if ( $#res > 3 ) {
>>          my @riceCc;
>>          my @nonriceCc;
>>          @riceCc = grep /rice.edu/i, @res;
>>          @nonriceCc = grep !/rice.edu/i, @res;
>>          $RT::Logger->debug("$#riceCc riceCcs, $#nonriceCc nonriceCcs");
>>          if ($#nonriceCc > 1) {
>>              @res = (@riceCc, @nonriceCc[0]);
>>          }
>>      }
>>
>>      return @res;
>> }
>> -----------------------
>
> Hi,
>
> I upgraded my RT version to 4.2.5, and this hack Ken gave me to limit 
> recipients number doesn't seem to work any more... (except if I missed 
> something in my tests)
>
> I didn't find any other solution and I was wondering if there was a 
> way to have this working in my RT version.
>
> Thanks
>
> -- 
> Olivier
>

Hi,

responding to myself if someone is interested...

I tested this (see below) and it works to limit to 10 recipients.


###### Modified Function to limit recipients number ######

sub ParseCcAddressesFromHead {
     my %args = (
         Head        => undef,
         QueueObj    => undef,
         CurrentUser => undef,
         @_
     );

     my $current_address = lc $args{'CurrentUser'}->EmailAddress;
     my $user = $args{'CurrentUser'}->UserObj;

     my @res =
         grep $_ ne $current_address && !RT::EmailParser->IsRTAddress( $_ ),
         map lc $user->CanonicalizeEmailAddress( $_->address ),
         map RT::EmailParser->CleanupAddresses( Email::Address->parse( 
$args{'Head'}->get( $_ ) ) ),
         qw(To Cc);

     @res = @res[0..9] if($#res > 9);

     return @res;
}


--
Olivier






More information about the rt-users mailing list