[rt-users] Looking for an example of how to send a different autoreply text based on the email address receiving the ticket
Emmanuel Lacour
elacour at easter-eggs.com
Wed Aug 17 09:35:57 EDT 2011
On Tue, Aug 16, 2011 at 01:59:46PM -0400, Gilbert Rebeiro wrote:
> Hi,
>
> We have 2 email addresses (1 for english speaking clients and 1 for
> french speaking clients) that receive ticket requests.
>
> I was wondering if anyone can help with an example of a scrip that
> would send a different autoreply (english reply if sent to
> support at domain.com) (french reply with sent to
> supporttechnique at domain.com) when a new ticket is created in the
> general queue depending on the email address that the ticket was
> sent to.
>
> So if I understand how it works, the template would contain some
> perl code that examines the email address to and auto-replies using
> one text else it replies with another text.
>
My idea (untested, needs error checking):
- create two standard templates: autoreply-fr, autoreply-en
- use a Custom action for the autoreply scrip with the following prepare code:
my $lang;
foreach my $header(qw(To Cc)) {
last (if $lang );
foreach my $recipient (Email::Address->parse($message->head->get( $header ) ) ) {
if ( $recipient =~ /^support\@domain\.com$/ ) {
$lang = 'en';
last;
} elsif ( $recipient =~ /^supporttechnique\@domain\.com$/ ) {
$lang = 'fr';
last;
}
}
}
# Default to english
$lang = 'en' unless ( $lang );
my $Template = RT::Template->new( $RT::SystemUser );
$Template->Load("autoreply-".$lang);
require RT::Action::Autoreply;
bless($self, 'RT::Action::Autoreply');
$self->{Argument} = 'Requestor';
$self->{TemplateObj} = $Template;
$self->Prepare;
return 1;
You can of course also use the header parsing code directly in the template, but I like the idea to have template per language.
More information about the rt-users
mailing list