Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PMGS / PMGG

PMGS and PMGG are interactive management tools for Proxmox Mail Gateway (PMG). Both scripts provide the same operations; pmgg.sh uses Turkish prompts and pmgs.sh uses English prompts. They combine bulk Who Object management, quarantine delivery, allowlist/blocklist administration, Postfix queue operations, Who regex/IP/network management, and What Object listing in one Bash script.

Requirements

  • A Proxmox Mail Gateway host with the pmgsh CLI available.
  • Bash.
  • jq for JSON parsing.
  • Permission to perform the requested PMG operations.

Installation

Place the desired script on the PMG host and make it executable:

chmod +x pmgg.sh
# or: chmod +x pmgs.sh

The script does not install packages or change PMG configuration until an operation is selected and confirmed. Install jq when required:

apt install jq

Usage

./pmgg.sh
./pmgg.sh --help
./pmgg.sh --version
./pmgg.sh --no-color

The CLI flags are:

  • --help, -h: Show help and exit.
  • --version, -v: Show the version and exit.
  • --no-color: Disable colored terminal output.

Unknown options return an error. The normal command starts the interactive menu.

Menu Modules

  1. Who Object bulk add: Add email addresses and domains in automatic, email-only, or domain-only mode. Existing records are skipped.
  2. Quarantine bulk delivery: Filter spam quarantine messages by sender, recipient domain, and optional dates. Dry-run mode lists matches without delivering them.
  3. Who Object bulk delete: Delete selected email or domain records, or confirm deletion of every record in a Who Object.
  4. Allowlist / Blocklist management: List, add, or delete email, domain, regex, IP, and CIDR records.
  5. Postfix queue management: List queues, delete queue IDs, flush selected messages, clear a queue, or flush all queues.
  6. Who Object regex / IP / network management: Add or delete regex, IP, and CIDR records.
  7. What Object listing: List What groups and the records contained in each group.

The main menu also provides L to display the newest log and H to display help. Use 0 to exit.

PMG API Behavior

The script uses pmgsh and jq rather than calling the PMG database directly.

  • Who groups are discovered with /config/ruledb/who.
  • Who group configuration is read from /config/ruledb/who/<group-id>/config because the group listing contains IDs.
  • Who records are read from /config/ruledb/who/<group-id>/objects.
  • Who record deletion uses /config/ruledb/who/<group-id>/objects/<object-id>, ensuring the actual record ID is deleted.
  • What groups are discovered with /config/ruledb/what, then their configuration and records are read from /config/ruledb/what/<group-id>/config and /config/ruledb/what/<group-id>/objects.
  • Allowlist and blocklist records use their respective /config/<list>/<type> endpoints.
  • Quarantine delivery uses /quarantine/content --id <id> --action deliver.
  • Postfix queue operations use /nodes/<node>/postfix/... endpoints.

Responses are checked for errors and HTTP-style status 4xx or 5xx text. JSON error details are extracted with jq when available in the response.

Logging

Each run creates a timestamped log in:

.pmg/logs/pmgg-YYYYMMDD-HHMMSS.log

The directory is relative to the script location. Informational, success, warning, and error messages are written to the log. The L menu option displays the newest log file.

Safety Notes

  • Review the selected records before bulk operations.
  • Use quarantine dry-run mode before real delivery.
  • Delete-all and queue-clearing operations require an explicit yes confirmation.
  • Run the script with an account that has only the PMG permissions required for the task.
  • Keep logs protected because they can contain object values, queue IDs, addresses, and operation results.
  • Test destructive actions on a small set before applying them broadly.
  • The script is intended for PMG hosts and requires a working pmgsh connection.

Examples

Start the normal interactive menu:

./pmgg.sh

Show help without connecting to PMG:

./pmgg.sh --help

Run in a non-color environment:

./pmgg.sh --no-color

Display the installed script version:

./pmgg.sh --version

About

Proxmox Mail Gateway Suite

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages