Global Whitelist via CSV

You can script something using the API which is accesible via the pmgsh tool on the Mail Gateway itself.

Here is the API documentation: https://pmg.proxmox.com/pmg-docs/api-viewer/index.html#/config/ruledb/who/{ogroup}/email

Such a command could then be:
Code:
pmgsh create config/ruledb/who/3/email --email "foo@bar.com"

Make sure that the who group does have the correct ID (3 in the example) by running pmgsh get config/ruledb/who.
 
  • Like
Reactions: Stoiko Ivanov
Thanks Aaron.

It works with CLI.

Could you provide an example using CURL?
I tried
curl -d "email=test@test.de" --insecure -X POST https://192.168.0.7:8006/api2/json/config/ruledb/who/3/email
whitout success.

Where do I include the credentials?

Kind regards
Frederik
 
Thanks Aaron.
This is for PVE only. Not PMG.

curl -s -k -b "ticket='PMG:root@pam:64A56DA0::ZUrrn...'&email=test@test.de" -H "CSRFPreventionToken: 64A56DA0:j/dg4ks..." -X POST https://192.168.0.7:8006/api2/json/config/ruledb/who/3/email/

still isn't working...
 
Last edited:
I forgot to mention, that the API works the same way. So far it looks okay, except that the parameter should be added as --data-urlencode 'email=foo@bar.com'

Do you get any errors back? Adding the -v will show HTTP return codes.
 
The ticket that you get in the first step, is only valid for two hours. So if it took too long, you need to request a new one. Getting a current ticket can be the first step in the script you build.

Plus, the call should be -b "PMGAuthCookie=PMG:root@…, not -b "ticket=…
 
curl -v -d --data-urlencode "email=test@test.de&CSRFPreventionToken='64A58DE0:...'&PMGAuthCookie='PMG:root@pam:64A58DE0::...=='" --insecure -X POST https://192.168.0.7:8006/api2/json/config/ruledb/who/3/email

still returns

"HTTP/1.1 401 No ticket"

Are these Params correct?
  • email
  • CSRFPreventionToken
  • PMGAuthCookie
 
curl -v -XPOST -H '64A...' -k -b "PMGAuthCookie=PMG:root@pam:64A5...&email=test@test.de" --insecure -X POST https://192.168.0.7:8006/api2/json/config/ruledb/who/3/email

returns

"HTTP/1.1 401 Permission denied - invalid csrf token"

The PMGAuthCookie seems to be correct.