Multiple Reply Addresses For A Single Queue

Hi All,

I have multiple email addresses associated with a single queue
For ex: abc@xyz.com as well as pqr@lmn.com pointing to the same queue “queue-one”

We only have an option to set either of these email address in the Reply Address field in the Queue Creation form.
However, I want to configure the reply address dynamically based on the email address…
For ex: If an end user sends an email to abc@xyz.com, auto-alert should be sent via that email as well as upon replies by end user, it should be redirected to the same email address
and vice versa for pqr@lmn.com

Has anyone configured this in RTracker…? Need help around this…

@knation @knation2 @GreenJimll

You can set the Reply-To header in your email templates, so add some Perl code using {} to decide what the outgoing Reply-To address should be.

The other option would be to overlay the function in RT::Interface::Email that handles setting the header

Isn’t this too difficult? I’d try to adapt the reply Template. When you put on the first line some code which sets From address based on Requestor addres, it should work as desired. See Customizing/Templates - RT 4.4.5 Documentation - Best Practical

I’m wondering why you just don’t have two queues? You can have the same group(s) of privileged users associated with each, same scrips, etc but each would have a different reply-to email address and you would mail into each one separately. Seems much easier to me. What am I missing?

basically we have multiple sub-orgs and there’s a need to keep some of the functions are common across these sub-orgs
for instance: network related, infosec related tickets

now these sub-orgs will have their own support email id for these functions but we want to just have one queue catering to these requests and reply-to address should be identified on the basis of the sub-org or the origin of the ticket.

hope this clears the requirement!

any reference to take a look at…?

how do I dynamically set the reply address based on the requestor…? also I want it to be decided by the queue email address.
for ex: if an end user is sending to abc@xyz.com, reply address should be abc@xyz.com and so on

Docs for customizing templates can be found here:
https://docs.bestpractical.com/rt/5.0.2/customizing/templates.html#Headers

I’d try something like this in a template:

RT-Attach-Message: yes
From: {
my $from = '111@111.com';
$from = '222@222.com' if ($Ticket->RequestorAddresses =~ /\@gmail.com/);
$from = '333@333.com' if ($Ticket->RequestorAddresses =~ /\@yahoo.com/);
$from = '444@444.com' if ($Ticket->RequestorAddresses =~ /\@hotmail.com/);
$from;
}

{$Transaction->Content()}

Well, after this you get the right From but RT will add Reply-To address to your queue addres. To avoid that add to the template header once more the same for Reply-To. So the final template would be:

RT-Attach-Message: yes
From: {
my $from = '111@111.com';
$from = '222@222.com' if ($Ticket->RequestorAddresses =~ /\@gmail.com/);
$from = '333@333.com' if ($Ticket->RequestorAddresses =~ /\@yahoo.com/);
$from = '444@444.com' if ($Ticket->RequestorAddresses =~ /\@hotmail.com/);
$from;
}
Reply-To: {
my $from = '111@111.com';
$from = '222@222.com' if ($Ticket->RequestorAddresses =~ /\@gmail.com/);
$from = '333@333.com' if ($Ticket->RequestorAddresses =~ /\@yahoo.com/);
$from = '444@444.com' if ($Ticket->RequestorAddresses =~ /\@hotmail.com/);
$from;
}    

{$Transaction->Content()}

thanks for the snippet… can this be implemented in a way where in all the auto-replies such as upon ticket creation, replies from technicians to enduser via rtracker, closure and any other mail related activities to follow the approach as expected…?

You can put this to whatever Template you want. Just look to Scrips, find what Templates they use and modify the Templates. Slightly updated code for efficiency (not so many database queries) is here:

RT-Attach-Message: yes
{
my $header1 = "From: ";
my $header2 = "Reply-To: ";
my $requestor = $Ticket->RequestorAddresses || "";
my $from = '111@111.com';
$from = '222@222.com' if ($requestor =~ /\@gmail.com/);
$from = '333@333.com' if ($requestor =~ /\@yahoo.com/);
$from = '444@444.com' if ($requestor =~ /\@hotmail.com/);
$from = $header1 . $from . "\n" . $header2 . $from;
$from;
}

{$Transaction->Content()}

Subject: AutoReply: {$Ticket->Subject}
RT-Attach-Message: yes
{
my $header1 = "From: ";
my $header2 = "Reply-To: ";
my $requestor = $Ticket->RequestorAddresses || “”;
my $from = ‘dummy-itsupport@abc.com’;
$from = ‘dummy-itsupport@pqr.in’ if ($requestor =~ /@pqr.in/);
$from = $header1 . $from . “\n” . $header2 . $from;
$from;
}
Content-Type: text/html

Greetings,

This message has been automatically generated in response to the creation of a trouble ticket regarding {$Ticket->Subject()}, a summary of which appears below.

There is no need to reply to this message right now. Your ticket has been assigned an ID of {$Ticket->SubjectTag}.

Please include the string {$Ticket->SubjectTag} in the subject line of all future correspondence about this issue. To do so, you may reply to this message.

Thank you,
{$Ticket->QueueObj->CorrespondAddress()}


{$Transaction->Content(Type => 'text/html')}

this is what I have in the Autoreply To Requestor template but is not working.

You might need to escape the @ in that pattern, otherwise Perl will be looking for an array called pqr.

1 Like

From is not getting set to the email id I want to set… whereas reply-to address is getting set appropriately…
please suggest

The reason was explained by @GreenJimll. Escape the @ or use another style of regexp match. Either like this:

$from = 'dummy-itsupport@pqr.in' if ($requestor =~ /\@pqr.in/);

or this:

$from = 'dummy-itsupport@pqr.in' if ($requestor =~ m'@pqr.in');

doesnt work even after escaping @
Subject: AutoReply: {$Ticket->Subject}
RT-Attach-Message: yes
{
my $header1 = "From: ";
my $header2 = "Reply-To: ";
my $requestor = $Ticket->RequestorAddresses || “”;
my $from = ‘dummy-itsupport@abc.in’ if ($requestor =~ m’@abc.in’);
$from = ‘dummy-itsupport@pqr.com’ if ($requestor =~ m’@pqr.com’);
$from = $header1 . $from . “\n” . $header2 . $from;
$from;
}
Content-Type: text/html

Is it failing on both From: and Reply-To: now or still just not setting the From: ?

Just as an aside, are you applying this globally? If so, check there isn’t another template also called Autoreply set up for the queue which it’s using instead?

Admin → Queues → (select) → Templates
vs
Admin → Global → Templates

That’s got me in the past. Modifying one and wondering why it’s not having any effect!

There should also be errors in the RT logs if there is a problem with the code/syntax that you can look for

Also assuming that $Ticket->RequestorAddresses contains only one address of a requestor. And that after this code you have at least one void line in your template and some text or {$Transaction->Content()} afterwards.

What you could also do is dump out the contents of $requestor just after you create it (with something like warn or RT::Logger->warn()) and see what the string you’re actually trying to do the regexp against is.

I’d also separate out the instantiation of my $from; from the initial conditional assignment to it, so you can give it a default value if neither pattern matches. In other words have something like this:


my $from = 'default@example.com';
$from = 'dummy-itsupport@abc.in' if ($requestor =~ /\@abc.in/);
$from = 'dummy-itsupport@pqr.com' if ($requestor =~ /\@pqr.com/);