Email filter help

Discussion in 'ISPConfig 3 Priority Support' started by gvvg, Feb 23, 2021.

  1. gvvg

    gvvg New Member HowtoForge Supporter

    Hi,
    I cannot get the email filter to work.
    I am looking to delete mail arriving from a specific email address.
    I have created a filter
    Choosen
    Source -> header
    Contains
    email address from
    action delete
    active checked
    this doesn't work.
    I am using ISPconfig version 3.2.2
    it is up to date.
    Thanks in advance
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Post the rules that have been generated from your settings, you can find it on the custom rules tab.
     
  3. gvvg

    gvvg New Member HowtoForge Supporter

    ### BEGIN FILTER_ID:24
    if header :regex "[email protected]" [".*"] {
    discard;
    stop;
    }
    ### END FILTER_ID:24
    ### BEGIN FILTER_ID:23
    if header :regex "[email protected]" [".*"] {
    discard;
    stop;
    }
    ### END FILTER_ID:23
    ### BEGIN FILTER_ID:22
    if header :regex "[email protected]" [".*"] {
    discard;
    stop;
    }
    ### END FILTER_ID:22
     
  4. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    You entered the fields incorrectly, when using regex you have to specify the header and the regex to match; in your case it is looking for a header named '[email protected]' with any content. It sounds like you want to look for a 'From' header content '[email protected]'. A regex match uses a double slash as an escape char, so try entering:
    Code:
    From: email1@yyyyy\\.com
    And if you want to match the smtp envelope sender, it is usually found in Return-path, so you might add a second rule with:
    Code:
    Return-path: <?email1@yyyyy\\.com>?
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Or do it the easy way and select 'From' as source in the filter wizard, then contains. Using regex as you did is not required.
     
  6. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Hah, yes, good point. :)
     
  7. gvvg

    gvvg New Member HowtoForge Supporter

    I initially tried "from" and "is" with the email address but it didn't work.
    I've made the changes and now the waiting starts.
    I'll report back.
    Thank you both!
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    This can't work as the email address is not [email protected], it just contains [email protected]. You can see that when you look at the source of an email in your mail client, an email address is something like "John Doe <[email protected]>", so 'contains' must be used, unless you specify the full address.
     
  9. gvvg

    gvvg New Member HowtoForge Supporter

    This is working great.
    The only issue is I would like the email to go to the trash or deleted folder.
    Is this possible?
     
  10. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Change the action from "Delete" to "Move to" and specify the folder name.
     

Share This Page