Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Email Filtering Regex Problem

Discussion in 'E-mail Discussion' started by Fluxman, Mar 3, 2019.

Tags:
  1. Fluxman

    Fluxman Registered

    Joined:
    Mar 3, 2019
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    UK
    cPanel Access Level:
    Root Administrator
    Hello,

    I want emails containing a PDF or JPG attachment from certain email addresses to be automatically moved to a folder. I'm using the cpanel Email filters.

    It works for all email addresses, except one, and I can't think why.

    The filter is (simplified):

    FROM matches regex:
    test\.com|@foo\.com|@bar\.com

    AND

    Body matches regex:
    name=[\s\S]*(\.jpg|\.pdf)
    (I use "[\s\S]*" because ".*" doesn't work if there are linebreaks in the filename, which can happen sometimes.)

    ACTIONS: Deliver to folder ...
    STOP PROCESSING RULES​

    So, for an example, an email with:
    From: "Test Name" <[email protected]>

    ...and the body containing:
    ...
    Content-Type: application/octet-stream; name=test.pdf
    Content-Transfer-Encoding: base64
    ...
    would be matched...which it is...in all cases except one... in this case it's always emails from "@foo.com" that are never matched.

    The pdfs are never huge...however for the one email address that doesn't work, sometimes the email is usually around 400kb... could the size of the body mean that the regex match fails for larger email?

    Many thanks for any insights.
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,534
    Likes Received:
    2,182
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @Fluxman,

    Do you notice a difference if you switch from a single filter rule to three separate filter riles (one for each individual domain name instead of defining those domains as part of a regular expression)?

    There's some discussion on the thread below you may find helpful as well (regarding filenames that are base64 encoded):

    Block custom attachments EXIM issue

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice