Postmaster Filter not filtering all emails

Moderator: crythias

Post Reply
jfreeman2nc
Znuny advanced
Posts: 136
Joined: 04 Oct 2010, 14:14
Znuny Version: 3.0.10; 3.1.4
Location: US, SC
Contact:

Postmaster Filter not filtering all emails

Post by jfreeman2nc »

I have setup Postmaster filter's to capture certain incoming emails in order to place the email in the appropriate queue. I have been seeing some issues where some of the emails are being routed correctly, while others are not. For example, I have a client named, Save-way, which is filtered so that when the domain name is .@save-way.com, subject contains (Save\b), or body contains (Save\b) it moves the email to the Save-way queue. I actually have three filters setup for this, Save-way domain filter, Save-way subject filter, and Save-way body filter. Along with searching for domain, body, or subject, each of the three filters have the criteria that the email has to be to example.username@email.com.

I have seen some cases where the subject line will have Save-way_07212011 or something with an underscore and the emails are not filtered correctly in these instances. I have also tried changing (Save\b) to (Save|way) with no better results. I just really want the filter to find any email with Save-way anywhere in the message to be routed to the appropriate queue, but it seems though little changes really cause issues with the filter. I also saw an example where Save-way's would not be filtered correctly.

I am just reaching out, as I am not that great with RegExp in the first place, and we are moving towards adding more clients and I just do not have time to look through and manually move the tickets that the filter did not detect.

Thank you for your help.
OTRS 3.1.4
Windows Server 2008 R2
MySQL

OTRS 3.0.10 - soon to be 3.0.12 or 3.1.4
Windows Server 2008 R2
MySQL DB
renee
Znuny expert
Posts: 241
Joined: 06 Feb 2009, 11:15
Znuny Version: 3.0.x
Company: Perl-Services.de
Contact:

Re: Postmaster Filter not filtering all emails

Post by renee »

\b means "word boundary" and an underscore is not a word boundary, so your RegEx does not match. To match "word boundary or underscore", you have to use "[\b_]" instead of "\b".
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
jfreeman2nc
Znuny advanced
Posts: 136
Joined: 04 Oct 2010, 14:14
Znuny Version: 3.0.10; 3.1.4
Location: US, SC
Contact:

Re: Postmaster Filter not filtering all emails

Post by jfreeman2nc »

So "(Save\b_)" would work in both instances? The word boundary is always present I just have a few instances where the underscore is present.

I have also had a few instances where I am just searching for a single name in the subject or body, in these cases I will just put "(word)" in the filter. This will work a majority of the time but if the subject has word/words it will not work. Is there just a way to make this all inclusive where it just searches for "word" exactly?
OTRS 3.1.4
Windows Server 2008 R2
MySQL

OTRS 3.0.10 - soon to be 3.0.12 or 3.1.4
Windows Server 2008 R2
MySQL DB
jfreeman2nc
Znuny advanced
Posts: 136
Joined: 04 Oct 2010, 14:14
Znuny Version: 3.0.10; 3.1.4
Location: US, SC
Contact:

Re: Postmaster Filter not filtering all emails

Post by jfreeman2nc »

For instance, I just received an email from a company, with the subject: A Question from CompanyX. The email was to the email address that OTRS is fetching fromm and my filter is setup as is in the attached screenshot. I just do not understand why it is not filtering the message to the proper queue, am I just missing something? Should I remove the To field? I just want to make sure that only emails going To a certain email and contain CompanyX go to a specified queue. It seems that parenthesis around a word only works from time to time, and if there is a \,_,or any other character around the word it totally throws off the filter.
You do not have the required permissions to view the files attached to this post.
OTRS 3.1.4
Windows Server 2008 R2
MySQL

OTRS 3.0.10 - soon to be 3.0.12 or 3.1.4
Windows Server 2008 R2
MySQL DB
renee
Znuny expert
Posts: 241
Joined: 06 Feb 2009, 11:15
Znuny Version: 3.0.x
Company: Perl-Services.de
Contact:

Re: Postmaster Filter not filtering all emails

Post by renee »

jfreeman2nc wrote:So "(Save\b_)" would work in both instances? The word boundary is always present I just have a few instances where the underscore is present.

I have also had a few instances where I am just searching for a single name in the subject or body, in these cases I will just put "(word)" in the filter. This will work a majority of the time but if the subject has word/words it will not work. Is there just a way to make this all inclusive where it just searches for "word" exactly?

no, this won't work. Your regular expression says:

Code: Select all

The regular expression:

(Save\b_)

matches as follows:
  
NODE                     EXPLANATION
----------------------------------------------------------------------
  (                        group and capture to \1:
----------------------------------------------------------------------
    Save                     'Save'
----------------------------------------------------------------------
    \b                       the boundary between a word char (\w)
                             and something that is not a word char
----------------------------------------------------------------------
    _                        '_'
----------------------------------------------------------------------
  )                        end of \1
----------------------------------------------------------------------
_ is a word char.

It should be "Save[\b_]"... You should learn more about regular expressions: http://www.regular-expressions.info/tutorial.html
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
renee
Znuny expert
Posts: 241
Joined: 06 Feb 2009, 11:15
Znuny Version: 3.0.x
Company: Perl-Services.de
Contact:

Re: Postmaster Filter not filtering all emails

Post by renee »

Is the mail really send to "example.username@email.com" or is this mail address in CC or BCC? Does the queue exist (no typo in it)? Is there a "conflict" with an other filter?
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
jfreeman2nc
Znuny advanced
Posts: 136
Joined: 04 Oct 2010, 14:14
Znuny Version: 3.0.10; 3.1.4
Location: US, SC
Contact:

Re: Postmaster Filter not filtering all emails

Post by jfreeman2nc »

Yes the mail is sent to "example.username@email.com," there are some instances where that address is CC, but every issue where the filter has not worked the email has been sent to the address that OTRS is fetching. I have seen the filter not work if the the to address is CC'd but that makes sense.

Also, from reading more about regex expressions, it seems that I really do not need parenthesis around CompanyX, I should be able to just enter "CompanyX."
OTRS 3.1.4
Windows Server 2008 R2
MySQL

OTRS 3.0.10 - soon to be 3.0.12 or 3.1.4
Windows Server 2008 R2
MySQL DB
renee
Znuny expert
Posts: 241
Joined: 06 Feb 2009, 11:15
Znuny Version: 3.0.x
Company: Perl-Services.de
Contact:

Re: Postmaster Filter not filtering all emails

Post by renee »

Try to escape the "@" in the mail address ("example.username\@email.com" - note the "\"). Without the actual mail that didn't get filtered it is hard to debug the error; can you post a sample mail (the source code of the mail not the parsed mail).
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
Post Reply