diff --git a/deploy/dovecot/vacation-2.3.conf.example b/deploy/dovecot/vacation-2.3.conf.example new file mode 100644 index 0000000..3d10f9d --- /dev/null +++ b/deploy/dovecot/vacation-2.3.conf.example @@ -0,0 +1,7 @@ +# Include only on a mail node with dovecot-sieve installed. +protocol lmtp { + mail_plugins = $mail_plugins sieve +} +plugin { + sieve_before = file:/var/lib/coulobre-vacation/%d/%n.sieve;bindir=~/.coulobre-sieve +} diff --git a/deploy/dovecot/vacation-2.4.conf.example b/deploy/dovecot/vacation-2.4.conf.example new file mode 100644 index 0000000..5dc8f84 --- /dev/null +++ b/deploy/dovecot/vacation-2.4.conf.example @@ -0,0 +1,11 @@ +# Include only on a mail node with dovecot-sieve installed. +protocol lmtp { + mail_plugins { + sieve = yes + } +} +sieve_script coulobre-vacation { + type = before + path = /var/lib/coulobre-vacation/%{user | domain}/%{user | username}.sieve + bin_path = ~/.coulobre-sieve +} diff --git a/deploy/panel.env.example b/deploy/panel.env.example index 5a455c4..9a69392 100644 --- a/deploy/panel.env.example +++ b/deploy/panel.env.example @@ -16,6 +16,8 @@ COULOBRE_BROKER_URL=amqp://coulobre:@127.0.0.1:5672/coulobre # These two switches also enable provisioners using the SSH service drop-ins. # COULOBRE_LOCAL_DNS_PUBLISHING=1 # COULOBRE_LOCAL_MAILBOX_PROVISIONING=1 +# COULOBRE_MAIL_ROUTING=1 +# COULOBRE_MAIL_VACATION=1 # COULOBRE_LOCAL_DATABASE_CREDENTIALS=1 # COULOBRE_LOCAL_MAILBOX_CREDENTIALS=1 # COULOBRE_REMOTE_MAILBOX_CREDENTIALS=1 diff --git a/docs/deployment.md b/docs/deployment.md index e45c9da..52340e8 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -1345,6 +1345,79 @@ Back up mail on the node that hosts the mailbox. The archive can be used to recover messages and folders into a newly provisioned mailbox with the same address. [Mailbox backup and restore](development.md#back-up-and-restore-a-mailbox) +## Configure mail routing and automatic replies + +Set up these features on the Postfix and Dovecot node, including when it runs +on a separate server. Upgrade the panel and that node to the same Coulobre +version and keep the existing mailbox provisioning worker enabled. + +### Enable aliases, forwarders, and catch-all + +Create the managed alias map once on the mail node. Keep its contents when +upgrading. + +```sh +if ! sudo test -e /etc/postfix/coulobre-aliases; then + printf '%s\n' '# Managed by Coulobre Panel' | + sudo tee /etc/postfix/coulobre-aliases >/dev/null + sudo chmod 0644 /etc/postfix/coulobre-aliases +fi +``` + +Set `virtual_alias_maps` in Postfix's `main.cf`. Put Coulobre's map first +if you have other maps, and give each Coulobre-managed mail domain a single +source for alias and catch-all rules. + +```ini +virtual_alias_maps = proxy:texthash:/etc/postfix/coulobre-aliases +smtpd_reject_unlisted_recipient = yes +``` + +Run `sudo postfix check` and `sudo postfix reload`. Set +`COULOBRE_MAIL_ROUTING=1` in `/etc/coulobre/panel.env`. Operators can opt a +hosting plan into catch-all and external forwarding separately. Plan changes +are checked when saving the next routing revision. To revoke an active +forwarder or catch-all, remove the rule and apply the update. + +From **Mail domains**, open **Manage routing**, then preview and apply your +routes. A route can have several destinations. Local destinations are +provisioned mailboxes on that domain. Catch-all sends unknown recipients +to one mailbox on the same domain. Leave it blank for normal rejection of +unknown recipients. The panel shows the last confirmed publication and any +publication error. For individual delivery failures, check Postfix's +delivery status notification and the mail node's logs. Verify forwarding +to external providers with real test mail because their SPF and DMARC +policies can affect delivery. [Postfix virtual aliases](https://www.postfix.org/virtual.5.html) + +### Enable scheduled automatic replies + +Install the distribution's `dovecot-sieve` package. Add the settings in +[the Dovecot 2.4 example](../deploy/dovecot/vacation-2.4.conf.example) on Ubuntu +26.04 or Debian 13, or +[the Dovecot 2.3 example](../deploy/dovecot/vacation-2.3.conf.example) on Ubuntu +24.04. If you already run Sieve, merge the configuration and keep the +Coulobre script in the sequence before personal scripts. Check the merged +configuration with `sudo doveconf -n` and reload Dovecot. A default Postfix +installation provides the local `sendmail` command used for replies. + +Set `COULOBRE_MAIL_VACATION=1` in `/etc/coulobre/panel.env`. Open +**Automatic replies** for a deployed mailbox and enter a subject and message. +Optional start and end times are in UTC. Sieve checks the schedule at +delivery. It continues the normal delivery and suppresses responses to +automatic mail and repeat responses to the same sender within seven days. +[Dovecot Sieve documentation](https://doc.dovecot.org/2.4.2/core/plugins/sieve.html) + +After changing either panel flag, run `panel_manage migrate --noinput`. +Restart `coulobre-panel`, `coulobre-worker`, `coulobre-beat`, and +`coulobre-mailbox-provisioner`. Customers and resellers can manage the +settings for their own accounts. Operators need view permissions for the +account and mailboxes and change permission for the mail domain or mailbox. + +The panel database keeps the last requested and confirmed settings. Include +the mail node's Coulobre state and `/var/lib/coulobre-vacation` in your +server backup if you use these features. Maildir-only archives contain +messages and folders. Reapply policy settings after a mailbox-only recovery. + ## Check and provision mail DNS Open **Check mail DNS** under **Mail domains**. The check reads MX and diff --git a/docs/development.md b/docs/development.md index c29614b..72c81c9 100644 --- a/docs/development.md +++ b/docs/development.md @@ -648,7 +648,7 @@ sudo systemctl enable --now coulobre-mail-apply.socket Grant the socket group only to the service identity responsible for mailbox provisioning. Send one version 1 or 2 mailbox manifest as UTF-8 JSON to -`/run/coulobre-mail-apply.sock`, with a limit of 4 KiB. Shut down the writing +`/run/coulobre-mail-apply.sock`, with a limit of 64 KiB. Shut down the writing half of the connection and read the JSON reply to EOF. For a valid manifest, the reply identifies the mailbox and reports `configured` or `failed`. The generated password stays in a root-only credentials file on the mail node. diff --git a/src/coulobre/hosting/admin.py b/src/coulobre/hosting/admin.py index 7f1725d..30acb90 100644 --- a/src/coulobre/hosting/admin.py +++ b/src/coulobre/hosting/admin.py @@ -62,6 +62,8 @@ class HostingPlanAdmin(admin.ModelAdmin): "database_limit", "mailbox_limit", "mailbox_quota_mib", + "allow_mail_catchall", + "allow_external_mail_forwarding", "website_storage_limit_mib", ) search_fields = ("name",) diff --git a/src/coulobre/hosting/mail_policies.py b/src/coulobre/hosting/mail_policies.py new file mode 100644 index 0000000..39f5e22 --- /dev/null +++ b/src/coulobre/hosting/mail_policies.py @@ -0,0 +1,114 @@ +from django.conf import settings +from django.core.exceptions import PermissionDenied, ValidationError +from django.db import transaction + +from coulobre.mail_policy import MailRouting, parse_mail_policy + +from .access import is_tenant, manages_account +from .models import HostingMailDomain +from .node_client import apply_on_local_node +from .resource_requests import lock_hosting_account, require_active_services + + +def mail_policy_available(kind): + return settings.LOCAL_MAILBOX_PROVISIONING and ( + settings.MAIL_ROUTING if kind == "routing" else settings.MAIL_VACATION + ) + + +def policy_account(resource): + if isinstance(resource, HostingMailDomain): + return resource.account + return resource.mail_domain.account + + +def validate_policy(resource, spec, account): + require_active_services(account) + if isinstance(spec, MailRouting): + validate_routing(resource, spec, account.hosting_plan) + else: + mailbox_ready = resource.__class__.objects.filter( + pk=resource.pk, + provisioning__finished_at__isnull=False, + provisioning__problem="", + ).exists() + if not mailbox_ready: + raise ValidationError( + "Provision this mailbox before setting replies." + ) + + +def validate_routing(domain, spec, plan): + if spec.catchall and not (plan and plan.allow_mail_catchall): + raise ValidationError("This hosting plan does not allow catch-all.") + mailboxes = domain.mailboxes.all() + if mailboxes.filter(local_part__in=spec.aliases).exists(): + raise ValidationError("An alias cannot replace a requested mailbox.") + provisioned = { + f"{local}@{domain.domain}" + for local in mailboxes.filter( + provisioning__finished_at__isnull=False, + provisioning__problem="", + ).values_list("local_part", flat=True) + } + if not provisioned: + raise ValidationError("Provision a mailbox on this mail domain first.") + for address in sorted(spec.destinations): + if address.endswith(f"@{domain.domain}"): + if address not in provisioned: + raise ValidationError( + f"Provision the mailbox {address} first." + ) + elif not (plan and plan.allow_external_mail_forwarding): + raise ValidationError( + "This hosting plan does not allow external forwarding." + ) + + +@transaction.atomic +def queue_policy(jobs, target, resource, spec, expected_revision, actor): + account = lock_hosting_account( + policy_account(resource).pk, customer_id=None + ) + if is_tenant(actor) and not manages_account(actor, account): + raise PermissionDenied + validate_policy(resource, spec, account) + existing = jobs.select_for_update().filter(**{target: resource}).first() + if policy_revision(existing) != expected_revision: + raise ValidationError("These settings changed. Reload and try again.") + manifest = spec.manifest() + if existing is None: + jobs.create(**{target: resource}, manifest=manifest) + elif existing.finished_at is None: + if existing.manifest != manifest: + raise ValidationError("Wait for the pending change to finish.") + else: + jobs.requeue(jobs.filter(pk=existing.pk), manifest=manifest) + + +def policy_revision(job): + return job.requested_at.isoformat() if job else "" + + +def apply_policy(job, resource): + spec = parse_mail_policy(job.manifest) + expected = ( + resource.domain if isinstance(spec, MailRouting) else str(resource) + ) + identity = ( + spec.domain if isinstance(spec, MailRouting) else spec.mailbox.address + ) + if expected != identity: + raise ValueError("The policy belongs to a different mail resource.") + try: + validate_policy(resource, spec, policy_account(resource)) + except ValidationError as error: + raise ValueError(" ".join(error.messages)) from None + apply_on_local_node( + spec, + "/run/coulobre-mail-apply.sock", + "mail node", + "mail policy", + identity=spec.identity(), + ) + return {"applied_manifest": job.manifest} diff --git a/src/coulobre/hosting/mail_policy_views.py b/src/coulobre/hosting/mail_policy_views.py new file mode 100644 index 0000000..49d79f8 --- /dev/null +++ b/src/coulobre/hosting/mail_policy_views.py @@ -0,0 +1,258 @@ +from datetime import UTC + +from django import forms +from django.contrib.auth.mixins import PermissionRequiredMixin +from django.core.exceptions import ValidationError +from django.http import Http404 +from django.shortcuts import redirect +from django.utils import timezone +from django.utils.decorators import method_decorator +from django.views.decorators.cache import never_cache +from django.views.generic import FormView +from django.views.generic.detail import SingleObjectMixin + +from coulobre.mail_policy import MailRouting, MailVacation, parse_mail_policy + +from .access import TenantScopeMixin, is_tenant +from .mail_policies import ( + mail_policy_available, + policy_account, + policy_revision, + queue_policy, + validate_policy, +) +from .models import ( + HostingMailbox, + HostingMailDomain, + MailRoutingPublication, + MailVacationPublication, +) + +POLICY_PERMISSIONS = { + "routing": "hosting.change_hostingmaildomain", + "vacation": "hosting.change_hostingmailbox", +} +VIEW_PERMISSIONS = ( + "hosting.view_hostingaccount", + "hosting.view_hostingmailbox", +) + + +def mail_policy_enabled(request, kind): + return ( + mail_policy_available(kind) + and getattr(request, "impersonation", None) is None + and ( + is_tenant(request.user) + or request.user.has_perms( + (*VIEW_PERMISSIONS, POLICY_PERMISSIONS[kind]) + ) + ) + ) + + +class MailPolicyForm(forms.Form): + revision = forms.CharField(required=False, widget=forms.HiddenInput) + + def __init__(self, *args, resource, **kwargs): + super().__init__(*args, **kwargs) + self.resource = resource + + def clean(self): + cleaned = super().clean() + if not self.errors: + try: + self.spec = self.make_spec(cleaned) + validate_policy( + self.resource, self.spec, policy_account(self.resource) + ) + except ValueError as error: + raise ValidationError(str(error)) from error + return cleaned + + +class MailRoutingForm(MailPolicyForm): + aliases = forms.CharField( + required=False, + max_length=65536, + widget=forms.Textarea(attrs={"rows": 8, "spellcheck": "false"}), + help_text=( + "Enter one alias per line, such as " + "sales = alice@example.net, bob@example.net. " + "Use the part before @ for each alias." + ), + ) + catchall = forms.CharField( + label="Catch-all mailbox", + required=False, + max_length=254, + help_text=( + "Enter a mailbox on this domain if your plan allows catch-all. " + "Leave blank to reject unknown recipients." + ), + ) + + def make_spec(self, cleaned): + aliases = {} + for line in cleaned["aliases"].splitlines(): + if not line.strip(): + continue + name, equals, targets = line.partition("=") + name = name.strip() + if not equals or not name: + raise ValueError( + "Enter one alias and its destinations per line." + ) + if name in aliases: + raise ValueError(f"The alias {name} occurs twice.") + aliases[name] = [target.strip() for target in targets.split(",")] + return MailRouting(self.resource.domain, aliases, cleaned["catchall"]) + + +class MailVacationForm(MailPolicyForm): + enabled = forms.BooleanField( + label="Send automatic replies", required=False + ) + subject = forms.CharField(max_length=160, required=False) + message = forms.CharField( + max_length=4000, + required=False, + widget=forms.Textarea(attrs={"rows": 7}), + ) + starts_at = forms.DateTimeField( + label="Start time (UTC)", + required=False, + widget=forms.DateTimeInput( + attrs={"type": "datetime-local", "step": 1} + ), + ) + ends_at = forms.DateTimeField( + label="End time (UTC)", + required=False, + widget=forms.DateTimeInput( + attrs={"type": "datetime-local", "step": 1} + ), + ) + + def make_spec(self, cleaned): + values = { + key: cleaned[key] for key in ("enabled", "subject", "message") + } + for key in ("starts_at", "ends_at"): + timestamp = cleaned[key] + values[key] = ( + timestamp.astimezone(UTC).isoformat(timespec="seconds") + if timestamp + else "" + ) + return MailVacation(self.resource.spec, **values) + + +@method_decorator(never_cache, name="dispatch") +class MailPolicyEditor( + TenantScopeMixin, PermissionRequiredMixin, SingleObjectMixin, FormView +): + template_name = "hosting/mail_policy_form.html" + + def has_permission(self): + return getattr(self.request, "impersonation", None) is None and ( + super().has_permission() + ) + + def get_permission_required(self): + return (*VIEW_PERMISSIONS, POLICY_PERMISSIONS[self.kind]) + + def get(self, request, *args, **kwargs): + self.load_resource() + return super().get(request, *args, **kwargs) + + def post(self, request, *args, **kwargs): + self.load_resource() + with timezone.override(UTC): + return super().post(request, *args, **kwargs) + + def load_resource(self): + if not mail_policy_available(self.kind): + raise Http404 + self.object = self.get_object() + self.job = getattr(self.object, self.kind, None) + + def get_form_kwargs(self): + return super().get_form_kwargs() | {"resource": self.object} + + def get_initial(self): + initial = {"revision": policy_revision(self.job)} + if self.job is None: + return initial + spec = parse_mail_policy(self.job.manifest) + if self.kind == "routing": + initial["aliases"] = "\n".join( + f"{name} = {', '.join(targets)}" + for name, targets in spec.aliases.items() + ) + initial["catchall"] = spec.catchall + else: + initial.update(spec.manifest()) + for name in ("starts_at", "ends_at"): + initial[name] = initial[name].removesuffix("+00:00") + return initial + + def get_context_data(self, **kwargs): + applied = ( + parse_mail_policy(self.job.applied_manifest) + if self.job and self.job.applied_manifest + else None + ) + return super().get_context_data( + account=policy_account(self.object), + job=self.job, + applied=applied, + title=self.title, + routing=self.kind == "routing", + **kwargs, + ) + + def form_valid(self, form): + if self.kind == "routing" and "preview" in self.request.POST: + return self.render_to_response( + self.get_context_data(form=form, preview=form.spec) + ) + try: + queue_policy( + self.publications.objects, + self.target, + self.object, + form.spec, + form.cleaned_data["revision"], + self.request.user, + ) + except ValidationError as error: + form.add_error(None, error) + return self.form_invalid(form) + return redirect(self.request.path) + + +class MailRoutingEditor(MailPolicyEditor): + queryset = HostingMailDomain.objects.select_related( + "account__hosting_plan" + ) + customer_relation = "account__customer" + reseller_relation = "account__reseller" + form_class = MailRoutingForm + publications = MailRoutingPublication + kind = "routing" + target = "mail_domain" + title = "Mail routing" + + +class MailVacationEditor(MailPolicyEditor): + queryset = HostingMailbox.objects.select_related( + "mail_domain__account__hosting_plan", + ) + customer_relation = "mail_domain__account__customer" + reseller_relation = "mail_domain__account__reseller" + form_class = MailVacationForm + publications = MailVacationPublication + kind = "vacation" + target = "mailbox" + title = "Automatic replies" diff --git a/src/coulobre/hosting/migrations/0044_mail_parity.py b/src/coulobre/hosting/migrations/0044_mail_parity.py new file mode 100644 index 0000000..496944d --- /dev/null +++ b/src/coulobre/hosting/migrations/0044_mail_parity.py @@ -0,0 +1,116 @@ +# Generated by Django 5.2.19 on 2026-11-22 09:54 + +import django.db.models.deletion +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("hosting", "0043_dns_parity"), + ] + + operations = [ + migrations.AddField( + model_name="hostingplan", + name="allow_external_mail_forwarding", + field=models.BooleanField( + default=False, + help_text=( + "Allow aliases to forward outside their mail domain." + ), + ), + ), + migrations.AddField( + model_name="hostingplan", + name="allow_mail_catchall", + field=models.BooleanField( + default=False, + help_text=( + "Allow a mailbox to receive otherwise unknown recipients." + ), + ), + ), + migrations.CreateModel( + name="MailRoutingPublication", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "requested_at", + models.DateTimeField(default=django.utils.timezone.now), + ), + ( + "last_dispatched_at", + models.DateTimeField(blank=True, null=True), + ), + ("started_at", models.DateTimeField(blank=True, null=True)), + ("finished_at", models.DateTimeField(blank=True, null=True)), + ("problem", models.TextField(blank=True)), + ("manifest", models.JSONField()), + ( + "applied_manifest", + models.JSONField(blank=True, default=dict), + ), + ( + "mail_domain", + models.OneToOneField( + on_delete=django.db.models.deletion.CASCADE, + related_name="routing", + to="hosting.hostingmaildomain", + ), + ), + ], + options={ + "abstract": False, + }, + ), + migrations.CreateModel( + name="MailVacationPublication", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "requested_at", + models.DateTimeField(default=django.utils.timezone.now), + ), + ( + "last_dispatched_at", + models.DateTimeField(blank=True, null=True), + ), + ("started_at", models.DateTimeField(blank=True, null=True)), + ("finished_at", models.DateTimeField(blank=True, null=True)), + ("problem", models.TextField(blank=True)), + ("manifest", models.JSONField()), + ( + "applied_manifest", + models.JSONField(blank=True, default=dict), + ), + ( + "mailbox", + models.OneToOneField( + on_delete=django.db.models.deletion.CASCADE, + related_name="vacation", + to="hosting.hostingmailbox", + ), + ), + ], + options={ + "abstract": False, + }, + ), + ] diff --git a/src/coulobre/hosting/models.py b/src/coulobre/hosting/models.py index b588013..2b01259 100644 --- a/src/coulobre/hosting/models.py +++ b/src/coulobre/hosting/models.py @@ -273,6 +273,14 @@ class HostingPlan(models.Model): "Applies to new mailbox requests. Leave blank for unlimited." ), ) + allow_mail_catchall = models.BooleanField( + default=False, + help_text="Allow a mailbox to receive otherwise unknown recipients.", + ) + allow_external_mail_forwarding = models.BooleanField( + default=False, + help_text="Allow aliases to forward outside their mail domain.", + ) website_storage_limit_mib = models.PositiveIntegerField( "website storage limit (MiB)", blank=True, @@ -1046,6 +1054,26 @@ class MailboxProvisioning(ProvisioningJob): quota_update = models.BooleanField(default=False) +class MailPolicyPublication(ProvisioningJob): + manifest = models.JSONField() + applied_manifest = models.JSONField(default=dict, blank=True) + + class Meta: + abstract = True + + +class MailRoutingPublication(MailPolicyPublication): + mail_domain = models.OneToOneField( + HostingMailDomain, on_delete=models.CASCADE, related_name="routing" + ) + + +class MailVacationPublication(MailPolicyPublication): + mailbox = models.OneToOneField( + HostingMailbox, on_delete=models.CASCADE, related_name="vacation" + ) + + class ServiceHealth(models.Model): node = models.CharField(max_length=63) service = models.CharField(max_length=24) diff --git a/src/coulobre/hosting/resource_requests.py b/src/coulobre/hosting/resource_requests.py index 9b32d3a..c584c5c 100644 --- a/src/coulobre/hosting/resource_requests.py +++ b/src/coulobre/hosting/resource_requests.py @@ -69,6 +69,13 @@ def create_mailbox_request(account_id, local_part, *, customer_id=None): {"local_part": "This mailbox has already been requested."} ) + routing = getattr(mail_domain, "routing", None) + if routing and any( + spec.local_part in settings.get("aliases", {}) + for settings in (routing.manifest, routing.applied_manifest) + ): + raise ValidationError({"local_part": "Remove the mail alias first."}) + plan = account.hosting_plan if plan and plan.mailbox_limit is not None: mailboxes = HostingMailbox.objects.filter(mail_domain__account=account) diff --git a/src/coulobre/hosting/tasks.py b/src/coulobre/hosting/tasks.py index e32e296..808d92d 100644 --- a/src/coulobre/hosting/tasks.py +++ b/src/coulobre/hosting/tasks.py @@ -34,6 +34,7 @@ from .backup_restores import ( ) from .backup_retention import plan_backup_expirations from .mail_dns_setup import sync_mail_dns +from .mail_policies import apply_policy, mail_policy_available from .models import ( AccountBackupExpiration, AccountBackupJob, @@ -45,6 +46,8 @@ from .models import ( DnsPublication, HostingMailDomain, MailboxProvisioning, + MailRoutingPublication, + MailVacationPublication, SitePhpSettings, SitePhpVersion, SiteSFTP, @@ -223,6 +226,19 @@ def dispatch_mailbox_provisioning(): MailboxProvisioning, provision_mailbox, MAILBOX_PROVISIONING_QUEUE ) + if mail_policy_available("routing"): + dispatch_provisioning_jobs( + MailRoutingPublication, + publish_mail_routing, + MAILBOX_PROVISIONING_QUEUE, + ) + if mail_policy_available("vacation"): + dispatch_provisioning_jobs( + MailVacationPublication, + publish_mail_vacation, + MAILBOX_PROVISIONING_QUEUE, + ) + @shared_task def dispatch_account_service_changes(): @@ -669,6 +685,40 @@ def apply_mailbox_provisioning(provisioning): provision_local_mailbox(provisioning.mailbox.spec) +@shared_task(acks_late=True, reject_on_worker_lost=True) +def publish_mail_routing(job_id): + if mail_policy_available("routing"): + run_provisioning_job( + MailRoutingPublication.objects.select_related( + "mail_domain__account__hosting_plan" + ), + job_id, + apply_mail_routing_job, + "Could not reach the mail node to apply routing. Try again.", + ) + + +def apply_mail_routing_job(job): + return apply_policy(job, job.mail_domain) + + +@shared_task(acks_late=True, reject_on_worker_lost=True) +def publish_mail_vacation(job_id): + if mail_policy_available("vacation"): + run_provisioning_job( + MailVacationPublication.objects.select_related( + "mailbox__mail_domain__account" + ), + job_id, + apply_mail_vacation_job, + "Could not reach the mail node to apply replies. Try again.", + ) + + +def apply_mail_vacation_job(job): + return apply_policy(job, job.mailbox) + + @shared_task(acks_late=True, reject_on_worker_lost=True) def create_account_backup(job_id): if settings.LOCAL_ACCOUNT_BACKUPS: diff --git a/src/coulobre/hosting/templates/hosting/account_detail.html b/src/coulobre/hosting/templates/hosting/account_detail.html index d43af59..f149fa5 100644 --- a/src/coulobre/hosting/templates/hosting/account_detail.html +++ b/src/coulobre/hosting/templates/hosting/account_detail.html @@ -205,12 +205,15 @@
| Domain | DNS | |
|---|---|---|
| Domain | DNS | {% if manage_mail_routing %}Routing | {% endif %}
| {{ domain }} | Check mail DNS | + {% if manage_mail_routing %} +Manage routing | + {% endif %}