Email filter - allow a email box to accept only unique email

Discussion in 'Tips/Tricks/Mods' started by Under_Lucas, Sep 25, 2018.

  1. Under_Lucas

    Under_Lucas New Member

    Hi
    I need your help, I have this strange request.
    I have an email box that I only want to allow a unique email address to be able to be accepted:

    orignial(at)original.com -> allow_only_original(at)original.com

    Is this possible to do on Mail Box -> custom rules ?
    Regards,
     
  2. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    I'm sure I don't understand what you want, because it sounds like you just described the out-of-the-box behavior. If I create a [email protected] mailbox, it won't accept mail for [email protected] or [email protected] or any other address unless you do something to make it do so (eg. add an email alias, forward or catch-all).

    Do you mean match on an email header and only allow that maybe, or ???
     
  3. Under_Lucas

    Under_Lucas New Member

    I know this is awkward, but what I need it's an email account created on ispconfig (email @ mydomain.net), to accept only emails from a specific outside email address. ex: I want (outside email email @ werid.req) be the only email allowed to be accepted on the email I've created on Postfix email box (email @ mydomain.net).

    email @ werid.req -> email @ mydomain.net (succeed)
    any @ any.com -> email @ mydomain.net (drop/delete/ignored)
     
  4. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Ah, that makes sense. In email there are 2 "sender" addresses you come across, the smtp envelope sender and the address in the From: header (if any), and you can use custom rules to match either or both. As the From: header can be faked, or even empty, the envelope sender may be what you want. This should work for a simple case (this is the entire custom filter):
    Code:
    require ["envelope"];
    
    if not envelope "from" "[email protected]"
    {
      discard;
      stop;
    }
    And if you happen to use SRS, you'll want to match both the original address and the corresponding component in the rewritten sender, ie.:
    Code:
    require ["envelope"];
    
    if not anyof (
      envelope "from" "[email protected]",
      envelope :contains "from" "=weird.req=email@"
    ) {
      discard;
      stop;
    }
    Note that ISPConfig will add a "keep;" at the end, so you don't need to yourself. Also ensure the "Move Spam Emails to Junk directory." checkbox is off under the Mail Filter tab, or it will do junk mail filtering to the spam folder ahead of your custom rule.
     
    Under_Lucas and till like this.
  5. Under_Lucas

    Under_Lucas New Member

    Thanks for your help
     

Share This Page