Create Mail Filter rules via API

jors

Member
Apr 10, 2012
21
2
23
Hi there,

I am trying to guess how can I create Mail Filter rules via API (pmgsh). I did some testing:


# Added a domain as a permitted relay
$ pmgsh create /config/domains --domain test1.tld

# Added a Who object
$ pmgsh create /config/ruledb/who --name "Domain test.tld"
200 OK
26

# Added the domain to the Who object
$ pmgsh create /config/ruledb/who/26/domain --domain="test1.tld"
200 OK
40

# Created an empty rule for the domain
$ pmgsh create /config/ruledb/rules --name "Mark Spam (Level 5) test1.tld" --priority 83 --active 1 --direction 0
200 OK
16

# And don't know how to add objects to the rule, so I am stuck here
$ pmgsh create /config/ruledb/rules/16/action help
400 too many arguments
create config/ruledb/rules/16/action --ogroup <integer> [OPTIONS]



I tried adding to the rule the Who object, but even if it says OK, it didn't work because the Who object has not been added to the rule:

$ pmgsh create /config/ruledb/rules/16/to --ogroup 40
200 OK


I am missing what that --ogroup refers to. Any hint?

Kind regards.
 
I am missing what that --ogroup refers to. Any hint?
this refers to the 'who' object
a rule can only contain who/what/when/action objects
so the correct call would be

$ pmgsh create /config/ruledb/rules/16/to --ogroup 26

as you wrote your who object has the id 26
 
this refers to the 'who' object
a rule can only contain who/what/when/action objects
so the correct call would be

$ pmgsh create /config/ruledb/rules/16/to --ogroup 26

as you wrote your who object has the id 26

Makes sense and works, thank you!

Kind regards.