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

rogerw

Member
Feb 21, 2012
23
4
53
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 "[email protected]"
  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!
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,237
463
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 "[email protected]"
  4. Fail with the message: Error - Sorry this mailbox is unmonitored.
  5. Then: Discard Message
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.