[Web][Postfix] Add mail policies: per-recipient send/receive rules for mailboxes and groups

This commit is contained in:
FreddleSpl0it committed 2026-11-07 15:55:43 +01:00
1 parent 329bca1d46
commit 4484cfcd42
36 files changed
+2677 -42

No files matched your search

+368 -2
View File
@@ -1365,7 +1365,7 @@ paths:
description: show the group address as SOGo identity (needs sender_allowed)
type: boolean
internal:
description: only accept mail from senders of the domain
description: only accept mail from logged-in senders of the domain
type: boolean
template_id:
description: mailbox template applied to the members (admin only), empty = none
@@ -1377,6 +1377,115 @@ paths:
type: boolean
type: object
summary: Create group
/api/v1/add/mail-policy:
post:
responses:
"401":
$ref: "#/components/responses/Unauthorized"
"200":
content:
application/json:
examples:
response:
value:
- log:
- mail_policy
- add
- policy
- domain: example.org
name: Trainees
send_mode: internal
groups:
- "7"
msg:
- mail_policy_added
- Trainees
type: success
schema:
properties:
log:
description: contains request object
items: {}
type: array
msg:
items: {}
type: array
type:
enum:
- success
- danger
- warning
- error
type: string
type: object
description: OK
headers: {}
tags:
- Mail policies
description: >-
Create a mail policy (admins; domain admins with the "mail_policies"
ACL for their domains). Postfix checks the policies for every
recipient: every policy of the sending mailbox and of the addressed
mailbox or group must allow the mail, otherwise the recipient is
refused with 550 5.7.1.
operationId: Create mail policy
requestBody:
content:
application/json:
schema:
example:
domain: example.org
name: Trainees
send_mode: internal
send_allow:
- partner.example
receive_mode: all
receive_block:
- group:8
groups:
- "7"
active: "1"
properties:
domain:
description: domain of the policy (required)
type: string
name:
description: unique per domain, max. 100 characters
type: string
description:
description: max. 255 characters
type: string
send_mode:
description: all; internal = recipients in the domain of the policy and its alias domains plus send_allow; list = send_allow only
type: string
send_allow:
description: addresses, domains or group:<id> (array or list separated by commas, spaces or newlines), max. 500
type: array
send_block:
description: recipients that are always refused, entries as send_allow
type: array
receive_mode:
description: all; internal = senders logged in with a mailbox of the domain plus receive_allow; list = receive_allow only
type: string
receive_allow:
description: entries as send_allow; addresses and domains of this mailcow count for logged-in senders only
type: array
receive_block:
description: senders that are always refused, entries as receive_allow
type: array
reject_text:
description: text of the 550 5.7.1 rejection, printable ASCII, max. 200 characters, empty = default text
type: string
mailboxes:
description: mailboxes of the domain the policy applies to (replaces the list)
type: array
groups:
description: group IDs of the domain the policy applies to, also to mail to the group address (replaces the list)
type: array
active:
type: boolean
type: object
summary: Create mail policy
/api/v1/add/oauth2-client:
post:
responses:
@@ -2853,6 +2962,62 @@ paths:
type: object
type: object
summary: Delete groups
/api/v1/delete/mail-policy:
post:
responses:
"401":
$ref: "#/components/responses/Unauthorized"
"200":
content:
application/json:
examples:
response:
value:
- log:
- mail_policy
- delete
- policy
- id:
- "3"
msg:
- mail_policy_removed
- Trainees
type: success
schema:
properties:
log:
description: contains request object
items: {}
type: array
msg:
items: {}
type: array
type:
enum:
- success
- danger
- warning
- error
type: string
type: object
description: OK
headers: {}
tags:
- Mail policies
description: Delete mail policies by ID.
operationId: Delete mail policies
requestBody:
content:
application/json:
schema:
example:
- "3"
properties:
items:
description: contains list of policy IDs you want to delete
type: object
type: object
summary: Delete mail policies
/api/v1/delete/identity-link:
post:
responses:
@@ -4422,7 +4587,7 @@ paths:
description: show the group address as SOGo identity (needs sender_allowed)
type: boolean
internal:
description: only accept mail from senders of the domain
description: only accept mail from logged-in senders of the domain
type: boolean
template_id:
description: mailbox template applied to the members (admin only), empty = none
@@ -4497,6 +4662,106 @@ paths:
type: object
type: object
summary: Update groups
/api/v1/edit/mail-policy:
post:
responses:
"401":
$ref: "#/components/responses/Unauthorized"
"200":
content:
application/json:
examples:
response:
value:
- log:
- mail_policy
- edit
- policy
- id:
- "3"
receive_mode: internal
msg:
- mail_policy_modified
- Trainees
type: success
schema:
properties:
log:
description: contains request object
items: {}
type: array
msg:
items: {}
type: array
type:
enum:
- success
- danger
- warning
- error
type: string
type: object
description: OK
headers: {}
tags:
- Mail policies
description: >-
Update mail policies. Attributes you do not send keep their value. The
domain cannot be changed.
operationId: Update mail policies
requestBody:
content:
application/json:
schema:
example:
items:
- "3"
attr:
receive_mode: internal
properties:
attr:
properties:
name:
description: unique per domain, max. 100 characters
type: string
description:
description: max. 255 characters
type: string
send_mode:
description: all; internal = recipients in the domain of the policy and its alias domains plus send_allow; list = send_allow only
type: string
send_allow:
description: addresses, domains or group:<id> (array or list separated by commas, spaces or newlines), max. 500
type: array
send_block:
description: recipients that are always refused, entries as send_allow
type: array
receive_mode:
description: all; internal = senders logged in with a mailbox of the domain plus receive_allow; list = receive_allow only
type: string
receive_allow:
description: entries as send_allow; addresses and domains of this mailcow count for logged-in senders only
type: array
receive_block:
description: senders that are always refused, entries as receive_allow
type: array
reject_text:
description: text of the 550 5.7.1 rejection, printable ASCII, max. 200 characters, empty = default text
type: string
mailboxes:
description: mailboxes of the domain the policy applies to (replaces the list)
type: array
groups:
description: group IDs of the domain the policy applies to, also to mail to the group address (replaces the list)
type: array
active:
type: boolean
type: object
items:
description: contains list of policy IDs you want to update
type: object
type: object
summary: Update mail policies
/api/v1/edit/identity-provider-sync:
post:
responses:
@@ -6455,6 +6720,105 @@ paths:
may send as through groups.
operationId: Get group memberships
summary: Get group memberships
"/api/v1/get/mail-policy/{id}":
get:
parameters:
- description: id of the policy, or "all" (optionally followed by /domain1,domain2)
example: all
in: path
name: id
required: true
schema:
type: string
- description: e.g. api-key-string
example: api-key-string
in: header
name: X-API-Key
required: false
schema:
type: string
responses:
"401":
$ref: "#/components/responses/Unauthorized"
"200":
content:
application/json:
examples:
response:
value:
- id: 3
domain: example.org
name: Trainees
description: Trainees only send internally
send_mode: internal
send_allow:
- partner.example
send_block: []
receive_mode: all
receive_allow: []
receive_block:
- group:8
reject_text: ""
active: 1
mailboxes: []
groups:
- 7
created: "2026-11-07 12:00:00"
modified: null
can_edit: 1
description: OK
headers: {}
tags:
- Mail policies
description: >-
Mail policies visible to the caller (admins all, domain admins with the
"mail_policies" ACL their domains).
operationId: Get mail policies
summary: Get mail policies
"/api/v1/get/mail-policy/test/{sender}/{recipient}":
get:
parameters:
- description: envelope sender, "-" for the null sender (bounces)
example: trainee@example.org
in: path
name: sender
required: true
schema:
type: string
- description: recipient; append /login to test a sender logged in with its mailbox
example: someone@external.example
in: path
name: recipient
required: true
schema:
type: string
responses:
"401":
$ref: "#/components/responses/Unauthorized"
"200":
content:
application/json:
examples:
response:
value:
allowed: 0
side: send
policy: Trainees
internal_alias: 0
logged_in: 1
text: Sending to this recipient is not allowed by the mail policy of the sender
description: OK
headers: {}
tags:
- Mail policies
description: >-
Would Postfix accept the mail for this recipient? side is "send" or
"receive", policy is empty for a policy of another domain,
internal_alias = refused by the internal flag of an alias or group.
Domain admins test addresses of their domains. Empty answer for invalid
input.
operationId: Test mail policies
summary: Test mail policies
/api/v1/get/identity-provider/sync-status:
get:
responses:
@@ -8011,6 +8375,8 @@ tags:
description: Manage API keys
- name: Groups
description: Mailbox groups (distribution lists, send-as rights, templates)
- name: Mail policies
description: Whom mailboxes and groups may send to and receive from
- name: Routing
description: Define your own email routes
- name: Resources