The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to create a Global email filter on the command line?

Discussion in 'cPanel Developers' started by rogerw, Feb 2, 2017.

Tags:
  1. rogerw

    rogerw Member

    Joined:
    Feb 21, 2012
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Website Owner
    I reviewed the thread here:
    Creating global email filter via command line

    and the documentation here:
    UAPI Functions - Email::store_filter - Software Development Kit - cPanel Documentation

    Can a developer, or anyone help me here?

    I'm at a loss how to create the filter I need. What I'm trying to do is:
    1. Create a global email filter
    2. A filter name of: No Reply
    3. A rule for any email "To" that contains "no-reply@domain.com"
    4. Fail with the message: Error - Sorry this mailbox is unmonitored.
    5. Then: Discard Message
    Can anybody help me create the correct syntax for the rule?

    I know is should begin with:

    Code:
    uapi --user=username Email store_filter filtername=No Reply=no-reply%40DOMAIN.com action1=fail
    but I get lost after the "fail" (for "action1=") part.

    Thanks!
     
    #1 rogerw, Feb 2, 2017
    Last edited: Feb 2, 2017
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,288
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You can utilize a command such as:

    Code:
    uapi --user=$username Email store_filter filtername=No%20Reply action1=fail dest1=Error%20-%20Sorry%20this%20mailbox%20is%20unmonitored. part1=\$header_to: match1=contains val1=no-reply%40domain.com
    You do not need to discard the message if you are already bouncing it with the "Fail" action.

    Let us know if this helps.

    Thank you.
     
Loading...

Share This Page