diff --git a/src/coulobre/hosting/admin.py b/src/coulobre/hosting/admin.py
index 75ac3f6..95d7887 100644
--- a/src/coulobre/hosting/admin.py
+++ b/src/coulobre/hosting/admin.py
@@ -46,7 +46,13 @@ class HostingAccountAdmin(admin.ModelAdmin):
@admin.register(HostingPlan)
class HostingPlanAdmin(admin.ModelAdmin):
- list_display = ("name", "description", "database_limit", "mailbox_limit")
+ list_display = (
+ "name",
+ "description",
+ "database_limit",
+ "mailbox_limit",
+ "mailbox_quota_mib",
+ )
search_fields = ("name",)
def save_model(self, request, obj, form, change):
diff --git a/src/coulobre/hosting/migrations/0021_mailbox_storage_limits.py b/src/coulobre/hosting/migrations/0021_mailbox_storage_limits.py
new file mode 100644
index 0000000..adf82ff
--- /dev/null
+++ b/src/coulobre/hosting/migrations/0021_mailbox_storage_limits.py
@@ -0,0 +1,43 @@
+# Generated by Django 5.2.19 on 2026-11-21 11:56
+
+import django.core.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("hosting", "0020_account_backup_job"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="hostingmailbox",
+ name="quota_mib",
+ field=models.PositiveIntegerField(
+ blank=True,
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(1),
+ django.core.validators.MaxValueValidator(2147483647),
+ ],
+ verbose_name="storage limit (MiB)",
+ ),
+ ),
+ migrations.AddField(
+ model_name="hostingplan",
+ name="mailbox_quota_mib",
+ field=models.PositiveIntegerField(
+ blank=True,
+ help_text=(
+ "Applies to new mailbox requests. "
+ "Leave blank for unlimited."
+ ),
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(1),
+ django.core.validators.MaxValueValidator(2147483647),
+ ],
+ verbose_name="mailbox storage limit (MiB)",
+ ),
+ ),
+ ]
diff --git a/src/coulobre/hosting/models.py b/src/coulobre/hosting/models.py
index 8f12bd8..18d5041 100644
--- a/src/coulobre/hosting/models.py
+++ b/src/coulobre/hosting/models.py
@@ -1,7 +1,11 @@
import uuid
from django.conf import settings
-from django.core.validators import RegexValidator
+from django.core.validators import (
+ MaxValueValidator,
+ MinValueValidator,
+ RegexValidator,
+)
from django.db import models
from django.urls import reverse
from django.utils import timezone
@@ -19,7 +23,11 @@ from coulobre.dns_node import (
MxRecord,
TxtRecord,
)
-from coulobre.mail_node import LOCAL_PART_MAX_LENGTH, MailboxSpec
+from coulobre.mail_node import (
+ LOCAL_PART_MAX_LENGTH,
+ MAX_MAILBOX_QUOTA_MIB,
+ MailboxSpec,
+)
from .fields import DomainNameField
@@ -128,6 +136,18 @@ class HostingPlan(models.Model):
"Leave blank for unlimited. Enter 0 to block new mailbox requests."
),
)
+ mailbox_quota_mib = models.PositiveIntegerField(
+ "mailbox storage limit (MiB)",
+ blank=True,
+ null=True,
+ validators=[
+ MinValueValidator(1),
+ MaxValueValidator(MAX_MAILBOX_QUOTA_MIB),
+ ],
+ help_text=(
+ "Applies to new mailbox requests. Leave blank for unlimited."
+ ),
+ )
class Meta:
ordering = ("name", "pk")
@@ -252,6 +272,15 @@ class HostingMailbox(models.Model):
HostingMailDomain, on_delete=models.PROTECT, related_name="mailboxes"
)
local_part = models.CharField(max_length=LOCAL_PART_MAX_LENGTH)
+ quota_mib = models.PositiveIntegerField(
+ "storage limit (MiB)",
+ blank=True,
+ null=True,
+ validators=[
+ MinValueValidator(1),
+ MaxValueValidator(MAX_MAILBOX_QUOTA_MIB),
+ ],
+ )
class Meta:
ordering = ("mail_domain__domain", "local_part")
@@ -267,7 +296,9 @@ class HostingMailbox(models.Model):
@property
def spec(self):
- return MailboxSpec(self.mail_domain.domain, self.local_part)
+ return MailboxSpec(
+ self.mail_domain.domain, self.local_part, self.quota_mib
+ )
class WebProvisioningPlan(models.Model):
diff --git a/src/coulobre/hosting/resource_requests.py b/src/coulobre/hosting/resource_requests.py
index 33884b3..811d033 100644
--- a/src/coulobre/hosting/resource_requests.py
+++ b/src/coulobre/hosting/resource_requests.py
@@ -65,4 +65,7 @@ def create_mailbox_request(account_id, local_part, *, customer_id=None):
raise ValidationError(
"This hosting account has reached its mailbox limit."
)
- return mail_domain.mailboxes.create(local_part=spec.local_part)
+ return mail_domain.mailboxes.create(
+ local_part=spec.local_part,
+ quota_mib=plan.mailbox_quota_mib if plan is not None else None,
+ )
diff --git a/src/coulobre/hosting/templates/hosting/account_detail.html b/src/coulobre/hosting/templates/hosting/account_detail.html
index 5fcfbca..64526dd 100644
--- a/src/coulobre/hosting/templates/hosting/account_detail.html
+++ b/src/coulobre/hosting/templates/hosting/account_detail.html
@@ -174,6 +174,7 @@
@@ -181,6 +182,7 @@
{% for mailbox in mailboxes %}
Email address
+ Storage limit
{% if is_operator %}Deployment {% endif %}