# PATCH /domains/{name}/mail

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the mail group.

Update the domain's mail settings and spam policy

- Who may call it: administrator, reseller, customer
- Token scope, any of: mail, all
- Answers: 200 OK

Supply at least one setting to change. The API returns 400 if no setting is supplied or routing is invalid. An administrator, the domain's owner, or the owner's reseller can call this operation with a token that has the mail scope. Only an administrator can set outgoing, hourly_limit, account_hourly_limit, or outbound_ip. A 200 response returns the updated mail object and the mail reload result in reload.

Set routing to local to handle the domain's mail on this server, including mail sent by other domains on the server, and publish its mail records in the DNS zone. Set routing to remote when mail is hosted elsewhere. This server then refuses incoming mail for the domain. For a customer or reseller to set local routing, public DNS must direct the domain's mail to this server. UrbeStack checks A and AAAA records if there is no MX record. An administrator can set local routing before public DNS points here. Setting either mode ends any routing hold and disables automatic routing changes for the domain.

When mail settings are first created, routing starts as local if public DNS directs mail here or if the domain has no MX record and its nameservers are delegated to this server. Setting mail.unpointed_domains to accept also lets the domain start with local routing and no hold. Otherwise, routing starts as remote with mail on hold.

Set web to false to stop the domain's website from sending mail. Set outgoing to false to block all outgoing mail for the domain, including mail sent by accounts and scripts. The hourly_limit and account_hourly_limit fields set the domain-wide and per-account limits, respectively. Each accepts a whole number from 0 to 1000000 messages per hour. Use null or an empty string to restore the server default for either limit. The outbound_ip field selects a sending IP address from dns.ipv4, dns.ipv6, or mail.extra_addresses. Use null or an empty string to clear the override.

Spam filtering is on by default. Set spam to false to deliver mail without spam markings. When filtering is on, UrbeStack rejects mail at or above reject_score. For mail below that threshold, UrbeStack marks messages at or above junk_score as junk and delivers them to Junk if junk_folder is enabled. Both scores accept values from 0 to 100 with up to one decimal place. Use null or an empty string to restore the server default for either score. The junk_score must be below reject_score. Customers can set scores only within the range the administrator configured.

The junk_folder and greylisting fields inherit the server policy by default. Set greylisting to false to remove the first-contact delay. DKIM signing is on by default. Set dkim to false to stop signing if the domain uses external DNS without its DKIM record. UrbeStack keeps the key and record so signing resumes immediately when dkim is set to true.

## As commands

- [urbestack-mail-domain-set](https://urbestack.com/docs/commands/urbestack-mail-domain-set.md): Updates mail settings for the domain selected by --name.
- [urbestack-mail-domain-get](https://urbestack.com/docs/commands/urbestack-mail-domain-get.md): Shows a domain's mail settings, including its effective spam policy, mail accounts, forwarders, allow and block lists, and DKIM records.

## Parameters

- `name` (path, DomainName, required)

## Request body

JSON, the type [MailDomainPatch](https://urbestack.com/docs/api/types/MailDomainPatch.md).

- `account_hourly_limit` (integer, 0 to 1000000 or null): Administrator-only default hourly sending limit for each mail account in the domain.
- `dkim` (boolean): Whether to sign the domain's outgoing mail with DKIM. Set to false if the domain uses external DNS and its zone lacks the DKIM record.
- `greylisting` (boolean)
- `hourly_limit` (integer, 0 to 1000000 or null): Administrator-only limit on outgoing messages per hour for the domain. Use null for the server default or 0 for no limit.
- `junk_folder` (boolean): Whether messages marked as spam are moved to Junk.
- `junk_score` (number or null): Minimum score for marking a message as spam, or null for the server default. Customers must choose a score within the administrator's allowed range.
- `outbound_ip` (string, up to 45 characters or null): Administrator-only setting for which of the server's IP addresses to use for outgoing mail. Use null for the server default.
- `outgoing` (boolean): Administrator-only setting that blocks all outgoing mail for the domain when set to false.
- `reject_score` (number or null): Minimum spam score at which a message is rejected.
- `routing` (string, one of local, remote): With local, this server hosts the mailboxes and the domain's DNS zone contains the mail records. With remote, mail is hosted elsewhere.
- `spam` (boolean): Whether spam filtering is enabled for the domain.
- `web` (boolean): Whether the domain's website can send mail.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X PATCH "$API/domains/example.com/mail" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "account_hourly_limit": 1,
    "dkim": true,
    "greylisting": true,
    "hourly_limit": 1,
    "junk_folder": true,
    "junk_score": 1,
    "outbound_ip": "text",
    "outgoing": true,
    "reject_score": 1,
    "routing": "local",
    "spam": true,
    "web": true
  }'
```

Response, 200 OK:

```
{
  "mail": {
    "account_hourly_limit": 1,
    "accounts": [
      {
        "address": "info@example.com",
        "autoresponder": {
          "body": "text",
          "end": "text",
          "interval_days": 1,
          "start": "text",
          "subject": "text"
        },
        "created_at": "2026-09-09T10:15:00Z",
        "domain": "example.com",
        "home": "text",
        "hourly_limit": 1,
        "id": 1,
        "local_part": "text",
        "login_suspended": 1,
        "outgoing_suspended": 1,
        "quota_mb": 1,
        "updated_at": "text",
        "usage": {
          "messages": 1,
          "storage_kb": 1,
          "storage_limit_kb": 1
        }
      }
    ],
    "certificate": {
      "covers_mail": true,
      "covers_webmail": true,
      "installed": true
    },
    "check_resolvers": [
      "text"
    ],
    "default_address": {},
    "delegated_here": "yes",
    "dkim": [
      {}
    ],
    "dkim_selector": "text",
    "domain": "example.com",
    "filters": [
      {
        "action": {
          "action": "folder",
          "target": "https://example.com/new"
        },
        "address": "info@example.com",
        "created_at": "2026-09-09T10:15:00Z",
        "domain": "example.com",
        "id": 1,
        "name": "alice",
        "position": 1,
        "rules": {}
      }
    ],
    "forwarders": [
      {
        "address": "info@example.com",
        "created_at": "2026-09-09T10:15:00Z",
        "destinations": [
          "text"
        ],
        "domain": "example.com",
        "id": 1,
        "local_part": "text"
      }
    ],
    "hold": 1,
    "hold_checked_at": "text",
    "hold_ended_at": "text",
    "hold_ended_by": "text",
    "hold_nameservers": [
      "text"
    ],
    "hold_since": "text",
    "hourly_limit": 1,
    "lists": [
      {
        "created_at": "2026-09-09T10:15:00Z",
        "domain": "example.com",
        "entry": "text",
        "id": 1,
        "kind": "profile"
      }
    ],
    "outbound_ip": "text",
    "outgoing_suspended": 1,
    "policy": {
      "dkim": 1,
      "enabled": 1,
      "greylisting": 1,
      "junk_folder": 1,
      "junk_score": 1,
      "reject_score": 1
    },
    "public_nameservers": [
      "text"
    ],
    "records": [
      {
        "content": "text",
        "key": "panel.port",
        "name": "alice",
        "type": "rebuild",
        "zone": "text"
      }
    ],
    "routing": "text",
    "server_addresses": [
      "text"
    ],
    "server_policy": {},
    "smarthost": {
      "has_password": true,
      "host": "text",
      "port": 8443,
      "tls": true,
      "user": "alice"
    },
    "spam": {},
    "user": "alice",
    "web_sending": 1,
    "webmail_url": "text",
    "zone": "text"
  }
}
```

## Errors

- 400: --name is required
- 400: <ip> is not one of this server's addresses (dns.ipv4, dns.ipv6, mail.extra_addresses)
- 400: <what> must be a whole number from 0 to <max>
- 400: <what> must be text without control characters, 1 to <max> characters
- 400: A score is a number, with up to two decimals
- 400: Domain name required
- 400: Domain name too long
- 400: Invalid IPv4 address
- 400: Invalid IPv6 address
- 400: Invalid boolean
- 400: Invalid domain name
- 400: Invalid mail address
- 400: Invalid mail address: local part over 64 characters
- 400: Invalid mail address: no local part
- 400: Invalid mail address: the local part may hold letters, digits, dots, _ + and -
- 400: Invalid port
- 400: Invalid setting key
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: Nothing to change
- 400: Routing is local or remote
- 400: The junk score must be below the reject score
- 400: Username '<value>' is reserved
- 400: routing must be local or remote
- 401: Authentication required
- 404: No such domain: <name>
- 404: Setting '<key>' not found
- 409: The mail of <name> is not received here yet: its MX record 
