Skip to content

Commit

Permalink
Add IgnoreSubjectTicketForQueues config option and behaviour
Browse files Browse the repository at this point in the history
This adds the ability to configure a set of queues for which the
ticket number found in the subject tag of incoming emails is ignored,
forcing new tickets to be created in the queue specified by rt-mailgate.

An example use case is a setup where RTOwner is set to an address which
routes to RT (for example to a queue named 'bounces'). In order to avoid
loops, the queue should be set up to not have any scrips which send out
mail.

Without this patch, bounces which include the subject tag of the original
message in the subject line will be directed at the existing ticket,
rather than the intended behaviour of creating a new ticket in the
bounces queue. This could cause new emails to be sent out, and could
cause a mail loop.

This will only happen if the MTA sending the bounce includes the
original subject line in the subject line of bounces. One notable example
of this behaviour is Microsoft Exchange.

A more elaborate fix would be to not ignore the ticket ID completely,
but only if the specified queue did not match the ticket's queue.
In both cases it is necessary to make this configurable on a per-queue
basis, since this breaks some assumptions about RT's normal email
workflow.
  • Loading branch information
Dominic Hargreaves committed Jun 9, 2011
1 parent a2b11db commit 97f19a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions etc/RT_Config.pm.in
Expand Up @@ -359,6 +359,18 @@ Set($ExtractSubjectTagNoMatch, ( ${RT::EmailSubjectTagRegex}
? qr/\[(?:${RT::EmailSubjectTagRegex}) #\d+\]/
: qr/\[\Q$RT::rtname\E #\d+\]/));

=item C<@IgnoreSubjectTicketForQueues>

Set C<@IgnoreSubjectTicketForQueues> to a list of queue names which
should cause the mail gateway to bypass the extraction of ticket ID
from subject lines. This is probably only useful in esoteric cases,
such as when you are sending bounces back to a non-response queue in
RT.

=cut

Set(@IgnoreSubjectTicketForQueues, ());

=back

=head1 Outgoing Mail Configuration
Expand Down
6 changes: 5 additions & 1 deletion lib/RT/Interface/Email.pm
Expand Up @@ -1377,7 +1377,11 @@ sub Gateway {
}
# }}}

$args{'ticket'} ||= ParseTicketId( $Subject );
# Don't parse the ticket ID from the subject for nominated queues
unless (grep { $_ eq $args{'queue'} }
RT->Config->Get('IgnoreSubjectTicketForQueues')) {
$args{'ticket'} ||= ParseTicketId( $Subject );
}

$SystemTicket = RT::Ticket->new( $RT::SystemUser );
$SystemTicket->Load( $args{'ticket'} ) if ( $args{'ticket'} ) ;
Expand Down

1 comment on commit 97f19a4

@jmdh
Copy link
Owner

@jmdh jmdh commented on 97f19a4 Jun 28, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BPS people wondered if this could be done with a MailPlugin instead.

Please sign in to comment.