Skip to content

✨ Introduce configurable sending quotas#955

Merged
0x46616c6b merged 1 commit intomainfrom
Introduce-configurable-sending-quotas
Feb 22, 2026
Merged

✨ Introduce configurable sending quotas#955
0x46616c6b merged 1 commit intomainfrom
Introduce-configurable-sending-quotas

Conversation

@0x46616c6b
Copy link
Copy Markdown
Member

@0x46616c6b 0x46616c6b commented Jan 5, 2026

This pull request introduces configurable SMTP quota limits at both the global (settings), user, and alias levels, allowing administrators to restrict the number of emails sent per hour and per day. It adds support for these limits in the backend, exposes them via a new API endpoint, and updates the admin UI and translations accordingly. Comprehensive tests are included to ensure correct behavior.

SMTP Quota Limit Functionality

  • Added global settings for smtp_quota_limit_per_hour and smtp_quota_limit_per_day, including validation and display in the settings UI. [1] [2] [3]
  • Extended the User and Alias entities to support custom SMTP quota limits, with corresponding getter/setter methods and database mapping. [1] [2] [3] [4]
  • Introduced the reusable form type SmtpQuotaLimitsType for editing quota limits, and integrated it into the admin forms for users and aliases. [1] [2] [3] [4] [5]

API and Backend Enhancements

  • Added a new API endpoint /api/postfix/quota/{email} to retrieve the effective SMTP quota limits for a user or alias, defaulting to global settings if no custom limits are set. [1] [2] [3]
Bildschirmfoto am 2026-01-05 um 22 15 07 Bildschirmfoto am 2026-01-05 um 22 14 42 Bildschirmfoto am 2026-01-05 um 22 14 30

@0x46616c6b 0x46616c6b added the enhancement New feature or request label Jan 5, 2026
Comment thread config/settings.yaml Outdated

smtp_quota_limit_per_minute:
type: integer
default: 0
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to define some sensible defaults?

Copy link
Copy Markdown
Contributor

@nevart nevart Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these limits to be highly environment-dependent, I've no idea what these limits could be. Leaving them at "unlimited" seems okay to me; people need to set these limits themselves, if they want to rely on this feature.

Looking around, mailbox.org allows 10000 mails per day; posteo.de limits to 500 mails per hour and 1000 mails per day.

To ease adoption of this feature, we could think about an option to specifiy the action to take if a user breaches the limit. For example, to get started, while still figuring out which limits to use, it might be preferable to relax enforcement, i.e. "report / log", instead of "enforce". Not relly happy regarding these names, thats just a rough draft to describe the idea.

Comment thread src/Admin/UserAdmin.php
->add('passwordChangeRequired', CheckboxType::class, [
]);

if ($this->security->isGranted(Roles::ADMIN)) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only admins can set that per user, domain admins will not see that setting

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense.

@0x46616c6b 0x46616c6b force-pushed the Introduce-configurable-sending-quotas branch 3 times, most recently from 2bd2b11 to b14d0c7 Compare January 9, 2026 21:50
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jan 9, 2026

@0x46616c6b 0x46616c6b force-pushed the Introduce-configurable-sending-quotas branch 2 times, most recently from 3432120 to acded3a Compare February 15, 2026 12:12
Copy link
Copy Markdown
Contributor

@nevart nevart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't comment on the code itself, just added some general thoughts. Thanks so much for pushing this!

Comment thread src/Admin/UserAdmin.php
->add('passwordChangeRequired', CheckboxType::class, [
]);

if ($this->security->isGranted(Roles::ADMIN)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense.

Comment thread src/Controller/PostfixController.php Outdated
Comment thread config/settings.yaml Outdated

smtp_quota_limit_per_minute:
type: integer
default: 0
Copy link
Copy Markdown
Contributor

@nevart nevart Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these limits to be highly environment-dependent, I've no idea what these limits could be. Leaving them at "unlimited" seems okay to me; people need to set these limits themselves, if they want to rely on this feature.

Looking around, mailbox.org allows 10000 mails per day; posteo.de limits to 500 mails per hour and 1000 mails per day.

To ease adoption of this feature, we could think about an option to specifiy the action to take if a user breaches the limit. For example, to get started, while still figuring out which limits to use, it might be preferable to relax enforcement, i.e. "report / log", instead of "enforce". Not relly happy regarding these names, thats just a rough draft to describe the idea.

@nevart
Copy link
Copy Markdown
Contributor

nevart commented Feb 19, 2026

I thought about if it makes sense, to introduce Enum(SmtpQuotaRules) (similar to User($rules)) to complement this feature: this would allow to abstract the actual limits which are in effect, i.e. all accounts are assigned the default role.
Besides, there could be a bulk role, with increased limits. And another in between, as a middleground.

If new accounts are onboarded, which need extended limits, admins could just switch the role, instead of thinking specifically if the new limits should be 1000 or 2000.

@nevart
Copy link
Copy Markdown
Contributor

nevart commented Feb 19, 2026

Another thought: it might make sense to enable users to configure email addresses, to which mails sent wouldn't be counted against the SMTP quota.

Having this in place might enable people to reach the provider, even if over quota, if there is a need, for example because they started to send many mails for good reasons, but now would like to ask for increased limits.

Edit: I'm not sure if Userli actually knows about the destination of messages, probably not, so if true, the above isn't for Userli.

@0x46616c6b 0x46616c6b force-pushed the Introduce-configurable-sending-quotas branch from acded3a to 98d182b Compare February 22, 2026 09:35
@0x46616c6b 0x46616c6b force-pushed the Introduce-configurable-sending-quotas branch from 98d182b to dc03408 Compare February 22, 2026 09:36
@sonarqubecloud
Copy link
Copy Markdown

@0x46616c6b 0x46616c6b merged commit 25525ec into main Feb 22, 2026
11 checks passed
@0x46616c6b 0x46616c6b deleted the Introduce-configurable-sending-quotas branch February 22, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants