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.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!