Route to queue based on To-address

I’m trying to build an RT to save costs from a proprietary ticket system but I’ve hit a roadblock.
I have seen some posts about this issue before, but no conclusive solution to the problem.

We want to use One inbox for all of our supporttickets (for example
I collect these emails with use of Getmail over IMAP. Getmail then delivers the mails to RT-mailgate, which then creates the tickets and places them in the “general” queue.

However, we want to sort out the incomming emails based on the TO-address. For instance, we have a email that’s That address is routed to which then again is delivered to RT.
But we want this email to get queued into the FR-queue and not the generalqueue.
We can set up seperate mailboxes for each queue, but I find it a little inelegant solution.

Been searching the net and there is a few similar solutions, most revolve around doing a Scrip inside RT to make this work. I have been trying to do modifications of Jacob Baloul’s Scrip: For now it looks like this

# Emails we want to move
my $domains = {};

my %email_map = (
                   'support\@company\.com'         => "General",
                   'FR-support\@company\.com'        => "FR-support",
                   'DE-support\@company\.com'      => "DE-support",

#Check each of our defined emails for a match
foreach my $emailKey (keys %email_map ){
if($self->TicketObj->RequestorAddresses =~ /^.*?${emailKey}/) {
    # Email matches - move to the right queue

Problem is that “TicketObj->RequestorAdresses” gives the address where it was sent from, not where it was sent to.
I am trying to find the address where it was sent to but looking over the documentation I could not find any object that saved the To-address.

Does anyone have any insight on this or an alternative solution?


I made a little makeway in my searching of the documentaion.

under RT::Attachments there were a few functions named “Headers” “Niceheaders” or maybe
GetHeader $TAG ( that I hope can be GetHeader $TO)

Although this may work, in the beginning it says that RT:Attachments should not be called by itself but rather through the different APIS. Has anyone an Idea how to do this? Not a perl magician nor scrip expert.