Regular Expression to filter emails - Postmaster filter
Moderator: crythias
-
- Znuny newbie
- Posts: 11
- Joined: 28 Sep 2012, 07:12
- Znuny Version: 3.0.11
- Real Name: Kannan S
- Company: Zyme Solutions
Regular Expression to filter emails - Postmaster filter
We have a requirement where if the email originated from our domain ( ex : domain1.com) and if recepients are all our employees (whose email ids have domain1.com), we want this article to be routed as email-internal so that these interactions are not visible to customers. This is required since all are not part of OTRS and our management teams can be copied on tickets and they may want to follow up internally on the status within the company.
To accomodate this, i have set the following Postmaster filter:
Name : 1_Assign_Email_Internal (This is the first filter that gets executed)
Stop After Match = No
Filter Conditions :
Cc = ((.*)@domain1.com|())
To = ((.*)@domain1.com|())
From = ((.*)@domain1.com|())
Set Email Headers:
X-OTRS-Followup-ArticleType = email-internal
This is primarily to check if From (also has only domain1.com or empty) and (To also has only domain1.com or empty) and CC (also has only domain1.com or empty)
The above filter works only if To and CC or populated. If To or CC is not populated, the filter does not work.
I suspect my condition of empty with a | () does not seem to work. Can you kindly help with how to capture the empty condition?
Thanks,
Kannan
To accomodate this, i have set the following Postmaster filter:
Name : 1_Assign_Email_Internal (This is the first filter that gets executed)
Stop After Match = No
Filter Conditions :
Cc = ((.*)@domain1.com|())
To = ((.*)@domain1.com|())
From = ((.*)@domain1.com|())
Set Email Headers:
X-OTRS-Followup-ArticleType = email-internal
This is primarily to check if From (also has only domain1.com or empty) and (To also has only domain1.com or empty) and CC (also has only domain1.com or empty)
The above filter works only if To and CC or populated. If To or CC is not populated, the filter does not work.
I suspect my condition of empty with a | () does not seem to work. Can you kindly help with how to capture the empty condition?
Thanks,
Kannan
-
- Znuny guru
- Posts: 5018
- Joined: 13 Mar 2011, 09:54
- Znuny Version: 6.0.x
- Real Name: Renée Bäcker
- Company: Perl-Services.de
- Contact:
Re: Regular Expression to filter emails - Postmaster filter
Untested:
The regex should be
\@domain1.com|(^$)
Please note that this regex matches when any recipient is in domain1.com. Even when there are recipients outside domain1.com.
The regex should be
\@domain1.com|(^$)
Please note that this regex matches when any recipient is in domain1.com. Even when there are recipients outside domain1.com.
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
-
- Moderator
- Posts: 10169
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Regular Expression to filter emails - Postmaster filter
Match is match all (AND). To have an OR requires separate filter.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
-
- Znuny newbie
- Posts: 11
- Joined: 28 Sep 2012, 07:12
- Znuny Version: 3.0.11
- Real Name: Kannan S
- Company: Zyme Solutions
Re: Regular Expression to filter emails - Postmaster filter
Thankyou both for the responses.
crythias, From your earlier posts i understand that all the filter conditions are AND which i understand completely.
But within a regular expression i want to use a OR condition. Is that not possible? Please let me know.
reneeb, let me test your recommendation and get back. Thanks.
Thanks,
Kannan
crythias, From your earlier posts i understand that all the filter conditions are AND which i understand completely.
But within a regular expression i want to use a OR condition. Is that not possible? Please let me know.
reneeb, let me test your recommendation and get back. Thanks.
Thanks,
Kannan
Re: Regular Expression to filter emails - Postmaster filter
For the web OTRS interface, the "OR" condition can be used with the symbol " | ". As the example in the e-mail filters suggests, when you want to create a filter for me@example.com OR test@example.com, you have to write: (me|test)@example.com.
I have a question though.
Where can we find regexpressions for AND and NOT? For example, i want to create a filter for e-mails sent, whose subject contains the strings "This" AND "is" but NOT "Sparta". Any suggestions please? I was wondering if this could be implemented throught he web interface. If not, i could also edit the OTRS files.
Thank you in advance.
I have a question though.
Where can we find regexpressions for AND and NOT? For example, i want to create a filter for e-mails sent, whose subject contains the strings "This" AND "is" but NOT "Sparta". Any suggestions please? I was wondering if this could be implemented throught he web interface. If not, i could also edit the OTRS files.
Thank you in advance.
Re: Regular Expression to filter emails - Postmaster filter
Anyone? I am still trying to find a solution to this.
-
- Moderator
- Posts: 10169
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Regular Expression to filter emails - Postmaster filter
You can't really implement a "not", but you can use the "stop processing more rules" to some effect.
Since the rules process in alphabetical order, you could search for "This.*is.*.Sparta" and essentially do nothing with it, but stop processing more rules.
The next rule alphabetically can handle "This.*is.*" normally.
Since the rules process in alphabetical order, you could search for "This.*is.*.Sparta" and essentially do nothing with it, but stop processing more rules.
The next rule alphabetically can handle "This.*is.*" normally.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
-
- Znuny newbie
- Posts: 4
- Joined: 02 Mar 2016, 11:12
- Znuny Version: 3.1.9
Re: Regular Expression to filter emails - Postmaster filter
Good afternoon,
We're following your guidelines, but we did not get the dynamic filters to save the value of what was previously captured by regexp in OTRS version 5.0.14:
Please, can you help us?
Best regards,
We're following your guidelines, but we did not get the dynamic filters to save the value of what was previously captured by regexp in OTRS version 5.0.14:
Please, can you help us?
Best regards,
You do not have the required permissions to view the files attached to this post.
Re: Regular Expression to filter emails - Postmaster filter
only one capture is allowed in OTRS5 per Postmaster Filter, OTRS6 will have named captures(thanks to RenéeB)
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master
Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
"Testing": ((OTRS Community Edition)) and git Master
Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
-
- Znuny newbie
- Posts: 4
- Joined: 02 Mar 2016, 11:12
- Znuny Version: 3.1.9
Re: Regular Expression to filter emails - Postmaster filter
Thanks for your answer.jojo wrote:only one capture is allowed in OTRS5 per Postmaster Filter, OTRS6 will have named captures(thanks to RenéeB)
You mean that, we only can capture one field?
-
- Administrator
- Posts: 3963
- Joined: 18 Dec 2007, 12:23
- Znuny Version: Znuny and Znuny LTS
- Real Name: Roy Kaldung
- Company: Znuny
- Contact:
Re: Regular Expression to filter emails - Postmaster filter
Hi,
With a default OTRS 5 you can only capture one value. Maybe you can use https://opar.perl-services.de/dist/Enha ... lter-5.0.2 until OTRS 6 is released and stable. It's the from developer mentioned above (RenéeB)
- Roy
With a default OTRS 5 you can only capture one value. Maybe you can use https://opar.perl-services.de/dist/Enha ... lter-5.0.2 until OTRS 6 is released and stable. It's the from developer mentioned above (RenéeB)
- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO
Use a test system - always.
Do you need professional services? Check out https://www.znuny.com/
Do you want to contribute or want to know where it goes ?
Use a test system - always.
Do you need professional services? Check out https://www.znuny.com/
Do you want to contribute or want to know where it goes ?
-
- Znuny newbie
- Posts: 4
- Joined: 02 Mar 2016, 11:12
- Znuny Version: 3.1.9
Re: Regular Expression to filter emails - Postmaster filter
Thank you very much!!!root wrote:Hi,
With a default OTRS 5 you can only capture one value. Maybe you can use https://opar.perl-services.de/dist/Enha ... lter-5.0.2 until OTRS 6 is released and stable. It's the from developer mentioned above (RenéeB)
- Roy