Replying e-mails creates new ticket

User A from inside Organization works perfectly.
User B from outside Organization (different domain $rtname) creates a new ticket upon reply.
I have extracted the below lines from log file adding printing ID each time to know the moment when the ID is lost:
Any idea?

[18416] [Tue Feb 2 10:37:55 2021] [debug]: ID: ‘453’ (/opt/rt4/sbin/…/lib/RT/Ticket.pm:133)
[18428] [Tue Feb 2 10:38:48 2021] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt4/sbin/…/lib/RT/I18N.pm:290)
[18428] [Tue Feb 2 10:38:48 2021] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/html - Subjectless message (/opt/rt4/sbin/…/lib/RT/I18N.pm:290)
[18428] [Tue Feb 2 10:38:48 2021] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt4/sbin/…/lib/RT/I18N.pm:567)
[18428] [Tue Feb 2 10:38:48 2021] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt4/sbin/…/lib/RT/I18N.pm:567)
[18428] [Tue Feb 2 10:38:48 2021] [debug]: Mail from user #155 (randomemail@gmail.com) (/opt/rt4/sbin/…/lib/RT/Interface/Email/Auth/MailFrom.pm:94)
[18428] [Tue Feb 2 10:38:48 2021] [debug]: ID: ‘’ (/opt/rt4/sbin/…/lib/RT/Ticket.pm:133)
[18428] [Tue Feb 2 10:38:48 2021] [debug]: Tried to load a bogus ticket id: ‘’ (/opt/rt4/sbin/…/lib/RT/Ticket.pm:141)
[18428] [Tue Feb 2 10:38:48 2021] [debug]: ID: ‘454’ (/opt/rt4/sbin/…/lib/RT/Ticket.pm:133)

Thanks in advance.

Seems the subject for the incoming email isn’t set, how is user B sending the reply?

B is a google user and reply from gmail.

Can you get a copy of the subject header of the email that user B sent? Also does your Queue name contain any special characters?

Full headers of the e-mail reponsible to generate a new ticket.

Received: from VI1PR06MB6622.eurprd06.prod.outlook.com (2603:10a6:800:183::16)
by VI1PR06MB4671.eurprd06.prod.outlook.com with HTTPS; Tue, 2 Feb 2021
15:33:47 +0000
Received: from DU2PR04CA0100.eurprd04.prod.outlook.com (2603:10a6:10:230::15)
by VI1PR06MB6622.eurprd06.prod.outlook.com (2603:10a6:800:183::16) with
Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.24; Tue, 2 Feb
2021 15:33:46 +0000
Received: from DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com
(2603:10a6:10:230:cafe::33) by DU2PR04CA0100.outlook.office365.com
(2603:10a6:10:230::15) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend
Transport; Tue, 2 Feb 2021 15:33:46 +0000
Authentication-Results: spf=pass (sender IP is 209.85.215.182)
smtp.mailfrom=gmail.com; doma.in; dkim=pass (signature was verified)
header.d=gmail.com;doma.in; dmarc=pass action=none
header.from=gmail.com;compauth=pass reason=100
Received-SPF: Pass (protection.outlook.com: domain of gmail.com designates
209.85.215.182 as permitted sender) receiver=protection.outlook.com;
client-ip=209.85.215.182; helo=mail-pg1-f182.google.com;
Received: from mail-pg1-f182.google.com (209.85.215.182) by
DB5EUR03FT049.mail.protection.outlook.com (10.152.20.191) with Microsoft SMTP
Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
15.20.3784.11 via Frontend Transport; Tue, 2 Feb 2021 15:33:46 +0000
Received: by mail-pg1-f182.google.com with SMTP id o16so15126214pgg.5
for my@doma.in; Tue, 02 Feb 2021 07:33:46 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=CXmvBT3jQpBFb00+DGfzYU6YUZq4EzSlMvgUdUDSul4=;
b=mwPWid0sYDk79HovD4KCzTJhVXxKGYlllTCdWfvKSgVaiOTJXrlvTWvlcukV05gPra
uuEMsR2P4OI6mWkl/7OnXKZVUQx0n5eZRMjGK59OveEBZGuelcNajfxMwwHc51m7/oOZ
BjsRwpkq9XHTdJxte/7HgxguTUOduYKSErWMzPK7nj4z/25YZ+7kV02vwuBKAejeOuRX
KzRicy9YIoQ8Re+WndZ8LjgSg3aJjRYiDOkY53mRC0v6HRumZ9SGDbx9j6rN6TziRr2A
4OSJWV7XYVM1sNWMclvlTc1ZHF/omdCxhFbV5VWsHBn3UVW1sTQD3zVaYw4bzEm6xuFo
cTOw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=CXmvBT3jQpBFb00+DGfzYU6YUZq4EzSlMvgUdUDSul4=;
b=XgggJmCujBMaUXwok51UP6wWeiBuTAAJ5UrRhxOe275wA15x1ogYdMYgTfINpt+hJD
kUPVdcT1YJcbJW70BplAtI3RCwkcfIZ3HjKvieZr69Jyfarq04GEGN8k79C3bANZKD57
hW1FwPf4FdDeqUaynsOzxml5kR1vNedZ9ss5Ceto+oSkwOciOBfwkmKEEYHscCJ4PI3h
B84BIdw8pcMa/ClyKqzPIaPqaPfoSjVHnQHrJHzUbU46VL6kMbi5wz9xpOSSC+HuH0Kv
kW9q92zPLB+qmmhV+SpkStfa4O/MZS5oXZBdOhG/3JMmxQRq2A0cGfYtBx1IEdy+bQWO
9Lpw==
X-Gm-Message-State: AOAM532UKTriwsVN5LIyWbWba39u6oDYD81HtK/+/ouS+tquGc+5Gi4Z
iaSp8nj4Glu94lHCs+WjuulR/sVz5FFczyNZgCFK9U6nNQo=
X-Google-Smtp-Source: ABdhPJx1s3+xf1ZTkb3+YKNSiZBQnJ032JkUBgQhu7PhA0pLdPGF0ccpSrFxEEan5809zDklsg4Fe1dRBzyauNSxa5A=
X-Received: by 2002:a62:a108:0:b029:1c1:119b:8713 with SMTP id
b8-20020a62a1080000b02901c1119b8713mr21872012pff.74.1612280024490; Tue, 02
Feb 2021 07:33:44 -0800 (PST)
References: RT-Ticket-456@SECTION CACr3QeyH0zWtOh8CJp5en_POFBA11F43p24qWVveDFHrEQCG5A@mail.gmail.com
rt-4.4.2-19757-1612279858-1364.456-5-0@SECTION
In-Reply-To: rt-4.4.2-19757-1612279858-1364.456-5-0@SECTION
From: Random User randomuser@gmail.com
Date: Tue, 2 Feb 2021 16:33:33 +0100
Message-ID: CACr3Qezs5cSJF_enwjRoHfDdVPZrxX3-Mm=twDm_bkr607EPMA@mail.gmail.com
Subject: Re: [General: #456] TEST-1
To: my@doma.in
Content-Type: multipart/alternative; boundary=“00000000000023656405ba5c328c”
Return-Path: randomuser@gmail.com
X-MS-Exchange-Organization-ExpirationStartTime: 02 Feb 2021 15:33:46.2357
(UTC)
X-MS-Exchange-Organization-ExpirationStartTimeReason: OriginalSubmit
X-MS-Exchange-Organization-ExpirationInterval: 1:00:00:00.0000000
X-MS-Exchange-Organization-ExpirationIntervalReason: OriginalSubmit
X-MS-Exchange-Organization-Network-Message-Id:
9c16e5e6-7920-4701-a146-08d8c78fee21
X-EOPAttributedMessage: 0
X-EOPTenantAttributedMessage: 0b1691e4-b13f-4adc-84c6-895fbe2ef87e:0
X-MS-Exchange-Organization-MessageDirectionality: Incoming
X-MS-PublicTrafficType: Email
X-MS-Exchange-Organization-AuthSource:
DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Office365-Filtering-Correlation-Id: 9c16e5e6-7920-4701-a146-08d8c78fee21
X-MS-TrafficTypeDiagnostic: VI1PR06MB6622:
X-MS-Oob-TLC-OOBClassifiers: OLM:1051;
X-MS-Exchange-Organization-SCL: 1
X-Microsoft-Antispam: BCL:0;
X-Forefront-Antispam-Report:
CIP:209.85.215.182;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail-pg1-f182.google.com;PTR:mail-pg1-f182.google.com;CAT:NONE;SFS:(84050400001)(7636003)(42186006)(34206002)(564344004)(5660300002)(7596003)(33964004)(82202003)(76482006)(336012)(356005)(86362001)(55446002)(6666004)(73392003)(26005)(1096003)(8676002);DIR:INB;
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2021 15:33:46.1977
(UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 9c16e5e6-7920-4701-a146-08d8c78fee21
X-MS-Exchange-CrossTenant-Id: 0b1691e4-b13f-4adc-84c6-895fbe2ef87e
X-MS-Exchange-CrossTenant-AuthSource:
DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: Internet
X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR06MB6622
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.8027173
X-MS-Exchange-Processed-By-BccFoldering: 15.20.3805.021
X-Microsoft-Antispam-Mailbox-Delivery:
ucf:0;jmr:0;auth:0;dest:I;ENG:(20160514016)(750128)(520002050)(944506458)(944626604);
X-Microsoft-Antispam-Message-Info:
=?utf-8?B?dFY1cDQyeTJ5RUhnLytSc3lxMlY2Nm1vSk1odjlWcUg4U1pUL3VOb2U4a0p3?=
=?utf-8?B?Zk1HT1YvSEFVN0JubmU3dEpPMG5JdTdiT012cmE1S2VHekJYdkhsYWViUC93?=
=?utf-8?B?Vm5vS0NoT0dQbU94WW1WRXpXTkV2NkJaM2lxc1ZOQ3B2NDlxVWxpNlZScXhn?=
=?utf-8?B?RnRDdWhYdFl0Z24yRGZhWVBXdm9ab1h6d2ozM2xtbEhBTVVVQ2l1YisxTUtt?=
=?utf-8?B?eDlSU0psOUU5d2VIT3BsajIwK0J1NVFNR2RwQVFyOE8xcUd1ZVhIYXFUdEx0?=
=?utf-8?B?WU9IYjl1TkUxUXI5d2s0TmdGTWZKdmlzK21qOVJWbkl3aXgyYlNrWlJFQU1V?=
=?utf-8?B?NXFMcUJUN0Nvb0NqYnJmZUE4RmswQVNpUW10dGdrZlFxO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elhK?=
=?utf-8?B?dkRoYnV4NGRHTGI1Ylh3Y2tlenJyZ1YvaUhrV2ZTcjR6K3A2dHdTRzBUVnlO?=
=?utf-8?B?YWsxSVBsU3ZEbjBkcWVCYk9JMmR3PT0=?=
MIME-Version: 1.0

–00000000000023656405ba5c328c
Content-Type: text/plain; charset=“UTF-8”

SENDER REPLY-2

Missatge de support via RT my@doma.in del dia dt., 2 de febr. 2021 a
les 16:30:

RT-Support REPLY-1


Random User

–00000000000023656405ba5c328c
Content-Type: text/html; charset=“UTF-8”
Content-Transfer-Encoding: quoted-printable

SENDER REPLY-2
Missatge de support via RT <my@doma.in> del dia dt., 2 de febr. 2021 a les= 16:30:
RT-Suppo= rt REPLY-1


--
Random User

–00000000000023656405ba5c328c–

It seems this could be a bug with the multipart email, hopefully I can look more later today!

Greate,
If you think I can perform any action just tell me.

Thanks.

One thing to bear in mind looking at that email is that it appears to have gone through a Microsoft Exchange server. Exchange is notorious for messing around with headers (or “broken” as some people prefer to think of it :wink: ), so what came into the system from Gmail might not be what you can see in those headers.

It might not be an issue in debugging this particular case, but just something to be aware of.

Thanks for the advice,
for internal Organization e-mails requesting a ticket works fine using the Microsoft Exchange/Office365.
New ticket is generated each time using external gmail users requesting a ticket.

RT-workflow

I tested your example email and tried feeding it into my RT, I saw a bunch of warnings in RT but the email did successfully reply on the ticket who’s ID matched the subject ID.

The warnings do point to parts of the email being in very unexpected states, could be like Greenjim said were Exchange is messing with headers.

Its just strange that I don’t see the same logging as you do, which version of RT are you on?

The version is 4.4.2

RT-version

But there is a subject in message header … I won’t blame Exchange for messing the headers in this case - at least there is no punctuation, just nice ASCII :slight_smile: . Well maybe after the steps below which shows us what happened to the mail at the end. :slight_smile:

I assume the whole mail pipe setup is something like:
postfix -> procmail (or similar such as maildrop or sieve) -> rt-mailgate
So what says the mail.log and what says procmail.log? You’ve already posted what RT (rt-mailgate) says but maybe that’s not enough.

BTW you are using postfix so it would be maybe helpful to set in main.cf to show in mail.log some more details:

header_checks = regexp:/etc/postfix/header_checks

The header_checks file could be (cat /etc/postfix/header_checks):

/^X-RT-Ticket:/         INFO
/^Subject:/             INFO

It could be also useful to update all perl modules in the system or at least the ones responsible for decoding the e-mail. But do it rather in some testing environment :slight_smile:

Petr

Hi Petr,
I did your proposed actions on postfix, the result of
Requesting Ticket --> Replying Ticket From RT-Manager --> Re-Replaying to Manager From Requester

Seems the ticked ID is lost when rt-mailgate injects a reply to a existent ticket of the external user

START: REQUEST TICKET from Requester

feb 16 10:41:26 vmwebsrv00 postfix/pickup[6323]: 9238C10275B: uid=30 from=
feb 16 10:41:26 vmwebsrv00 postfix/cleanup[6327]: 9238C10275B: info: header Subject: [General: #468] AutoReply: TEST-1 from local; from=websrv00@my.domain
feb 16 10:41:26 vmwebsrv00 postfix/cleanup[6327]: 9238C10275B: info: header X-RT-Ticket: MY RT SITE NAME #468 from local; from=websrv00@my.domain
feb 16 10:41:26 vmwebsrv00 postfix/cleanup[6327]: 9238C10275B: message-id=<rt-4.4.2-27606-1613468486-244.468-7-0@my_rt_site_name>
feb 16 10:41:26 vmwebsrv00 postfix/cleanup[6327]: 9238C10275B: info: header Subject: AutoReply: TEST-1 from local; from=websrv00@my.domain
feb 16 10:41:26 vmwebsrv00 postfix/qmgr[6322]: 9238C10275B: from=websrv00@my.domain, size=2566, nrcpt=1 (queue active)
feb 16 10:41:27 vmwebsrv00 postfix/smtp[6329]: 9238C10275B: to=mygmailuser@gmail.com, relay=gmail-smtp-in.l.google.com[74.125.140.26]:25, delay=0.98, delays=0.04/0.02/0.58/0.34, dsn=2.0.0, status=sent (250 2.0.0 OK 1613468487 l26si1668871wmh.213 - gsmtp)
feb 16 10:41:27 vmwebsrv00 postfix/qmgr[6322]: 9238C10275B: removed

REPLY-1 from RT-Management web page

feb 16 10:51:31 vmwebsrv00 postfix/pickup[6323]: 488DE10275B: uid=30 from=
feb 16 10:51:31 vmwebsrv00 postfix/cleanup[6366]: 488DE10275B: info: header Subject: [General: #468] TEST-1 from local; from=websrv00@my.domain
feb 16 10:51:31 vmwebsrv00 postfix/cleanup[6366]: 488DE10275B: message-id=<rt-4.4.2-27606-1613469091-1640.468-5-0@my_rt_site_name>
feb 16 10:51:31 vmwebsrv00 postfix/cleanup[6366]: 488DE10275B: info: header X-RT-Ticket: MY RT SITE NAME #468 from local; from=websrv00@my.domain
feb 16 10:51:31 vmwebsrv00 postfix/qmgr[6322]: 488DE10275B: from=websrv00@my.domain, size=1254, nrcpt=1 (queue active)
feb 16 10:51:32 vmwebsrv00 postfix/smtp[6368]: 488DE10275B: to=mygmailuser@gmail.com, relay=gmail-smtp-in.l.google.com[74.125.140.27]:25, delay=0.87, delays=0.05/0.02/0.36/0.44, dsn=2.0.0, status=sent (250 2.0.0 OK 1613469092 h9si2235639wrr.9 - gsmtp)
feb 16 10:51:32 vmwebsrv00 postfix/qmgr[6322]: 488DE10275B: removed

RE-REPLAY-1 from Requester GENERATING A NEW TICKET AND NEW E-MAIL FOR THE Requester

feb 16 10:54:40 vmwebsrv00 postfix/pickup[6323]: 5556C10275B: uid=30 from=
feb 16 10:54:40 vmwebsrv00 postfix/cleanup[6371]: 5556C10275B: info: header X-RT-Ticket: MY RT SITE NAME #469 from local; from=websrv00@my.domain
feb 16 10:54:40 vmwebsrv00 postfix/cleanup[6371]: 5556C10275B: message-id=<rt-4.4.2-27620-1613469280-919.469-7-0@my_rt_site_name>
feb 16 10:54:40 vmwebsrv00 postfix/cleanup[6371]: 5556C10275B: info: header Subject: [General: #469] AutoReply: Re: [General: #468] TEST-1 from local; from=websrv00@my.domain
feb 16 10:54:40 vmwebsrv00 postfix/cleanup[6371]: 5556C10275B: info: header Subject: AutoReply: Re: [General: #468] TEST-1 from local; from=websrv00@my.domain
feb 16 10:54:40 vmwebsrv00 postfix/qmgr[6322]: 5556C10275B: from=websrv00@my.domain, size=3275, nrcpt=1 (queue active)
feb 16 10:54:40 vmwebsrv00 postfix/smtp[6374]: 5556C10275B: to=mygmailuser@gmail.com, relay=gmail-smtp-in.l.google.com[74.125.140.27]:25, delay=0.5, delays=0.04/0.02/0.11/0.33, dsn=2.0.0, status=sent (250 2.0.0 OK 1613469280 t18si1655025wro.69 - gsmtp)
feb 16 10:54:40 vmwebsrv00 postfix/qmgr[6322]: 5556C10275B: removed

RT-MAILGATE DEBUG SESSION

[27606] [Tue Feb 16 10:10:10 2021] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt4/sbin/…/lib/RT/I18N.pm:290)
[27606] [Tue Feb 16 10:10:10 2021] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/html - Subjectless message (/opt/rt4/sbin/…/lib/RT/I18N.pm:290)
[27606] [Tue Feb 16 10:10:10 2021] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt4/sbin/…/lib/RT/I18N.pm:567)
[27606] [Tue Feb 16 10:10:10 2021] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt4/sbin/…/lib/RT/I18N.pm:567)
[27606] [Tue Feb 16 10:10:10 2021] [debug]: Mail from user #155 (mygmailuser@gmail.com) (/opt/rt4/sbin/…/lib/RT/Interface/Email/Auth/MailFrom.pm:94)
[27606] [Tue Feb 16 10:10:10 2021] [warning]: Use of uninitialized value $id in concatenation (.) or string at /opt/rt4/sbin/…/lib/RT/Ticket.pm line 133. (/opt/rt4/sbin/…/lib/RT/Ticket.pm:133)
[27606] [Tue Feb 16 10:10:10 2021] [debug]: TICKET_ID: ‘’ (/opt/rt4/sbin/…/lib/RT/Ticket.pm:133)
[27606] [Tue Feb 16 10:10:10 2021] [debug]: Tried to load a bogus ticket id: ‘’ (/opt/rt4/sbin/…/lib/RT/Ticket.pm:141)
[27606] [Tue Feb 16 10:10:10 2021] [debug]: TICKET_ID: ‘470’ (/opt/rt4/sbin/…/lib/RT/Ticket.pm:133) <— GENERATE NEW ID

And this all is by mail? I am slightly confused because your logs start with from= without any address. I also miss some destination. For example my first line after connection of mailservers is

Feb 16 15:20:48 rt.mysite.cz postfix/cleanup[20902]: 1BXXXXX3E4: info: header Subject: Re: [MYQUEUETAG #123456] SOME SUBJECT from mailserver.mysite.cz[some ip address]; from=<user.address@some.mailserver.cz> to=<queuename@rt.mysite.cz> proto=ESMTP helo=<mailserver.mysite.cz>

Also I miss the log about the delivery from mailserver to RT, such as:

Feb 16 15:20:49 rt.mysite.cz postfix/local[20903]: 1BXXXXX3E4: to=<queuename@rt.mysite.cz>, relay=local, delay=1.3, delays=0.1/0/0/1.2, dsn=2.0.0, status=sent (delivered to command: /opt/rt4/bin/rt-mailgate --queue queuename   --action correspond --url https://localhost)

What says your /etc/aliases file about the allowed incomming addresses? There should be something like:

queuename: "|/opt/rt4/bin/rt-mailgate --queue queuename  --action correspond --url https://localhost"

Or is there something else? In my live setup I have procmail in the aliases pipe so the mail is accepted by postfix, then because of aliases config delivered through pipe to procmail and then finally supplied to the rt-mailgate.
I wonder why should rt-mailgate cut the subject of the mail delivered by mail system. There has to be something before what does that.

What’s your value for $EmailSubjectTagRegex ?

Q1
from=wwwrun (extra characters ‘<’ and ‘>’ remove the user)
I have configured RT user in a mail client (kmail / pop3) who pipe the e-mail to a rt-server using rt-mailgate to inject the e-mail to rt-server (rt-mailgate --queue General --action correspond --url http://rt.my.domain/ ).

Q2
Yes I have my aliases:
rtuser: “|/opt/rt4/bin/rt-mailgate --queue General --action correspond --url http://rt.my.domain/
General: “|/opt/rt4/bin/rt-mailgate --queue General --action correspond --url http://rt.my.domain/

Q3
I will try to debug the EmailSubjectTagRegex in order to find the moment when ticket ID is lost.

Current:
Set($EmailSubjectTagRegex, qr/[\Q$tag\E\s+#(\d+)\s*]/i);

Checked with the same result:
###Set($EmailSubjectTagRegex, qr/[\Q$tag\E\s+#(\d+)\s*] | ^Re:[\Q$tag:\E\s+#(\d+)\s*]/i );

Don’t include the brackets and id in $EmailSubjectTagRegex. ParseTicketId will already do that for you (in fact, it seems as if you copied the above from that function).

Change it to just Set($EmailSubjectTagRegex, qr/General/i); Or if you wanted several tags, e.g. Set($EmailSubjectTagRegex, qr/(?:Tag1|Tag2)/i);